Skip to content

bug: s3 ListObjectVersions with delimiter not returning file objects and returning wrong CommonPrefixes #5025

@rtkgeoff

Description

@rtkgeoff

Is there an existing issue for this?

No

  • I have searched the existing issues

Current Behavior

In a bucket with two objects:

  • dir/test
  • dir/subdir/test2

The ListObjectVersions is returning unexpected results using delimiter '/'. Given any of these prefixes:

  • ''
  • 'dir/'
  • 'dir/s'
  • 'dir/test'
  • 'dir/subdir'
  • 'dir/subdir/'
  • 'dir/subdir/te'
  • 'dir/subdir/test2'

the result is

{
    "CommonPrefixes": [
        {
            "Prefix": "dir/"
        }
    ]
}

which is wrong for all but the first 2 prefixes above.

Expected Behavior

When given a delimiter ListObjectVersions should return any file object versions whose key starts with the given prefix and contains no additional delimiters. The same is true for the directories listed in CommonPrefixes; they must start with the prefix but not contain any additional delimiters except for a final trailing one.

For a bucket with two objects:

  • dir/test
  • dir/subdir/test2

ListObjectVersions delimiter=/ and prefix=dir/ should return

{
  "CommonPrefix":[{"Prefix":"dir/subdir/"}],
  "Versions":[{"Key":"dir/test", ...}]
}

ListObjectVersions delimiter=/ and prefix=dir/t should return

{
  "Versions":[{"Key":"dir/test", ...}]
}

ListObjectVersions delimiter=/ and prefix=dir/s or prefix=dir/subdir should return

{
  "CommonPrefix":[{"Prefix":"dir/subdir/"}]
}

ListObjectVersions delimiter=/ and prefix=dir/subdir/ or prefix=dir/subdir/te or prefix=dir/subdir/test2should return

{
  "Versions":[{"Key":"dir/subdir/test2", ...}]
}

How are you starting LocalStack?

With a docker run command

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

docker run --rm -it -p 4566:4566 -e SERVICES=s3 localstack/localstack

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

aws --endpoint-url http://localhost:4566 s3 mb s3://mybucket
aws --endpoint-url http://localhost:4566 s3api put-bucket-versioning --bucket mybucket '--versioning-configuration={"Status":"Enabled"}'
echo foo > test
aws --endpoint-url http://localhost:4566 s3 cp test s3://mybucket/dir/test
aws --endpoint-url http://localhost:4566 s3 cp test s3://mybucket/dir/subdir/test2

aws --endpoint-url http://localhost:4566 s3api list-object-versions --bucket mybucket --prefix dir/ --delimiter '/'
aws --endpoint-url http://localhost:4566 s3api list-object-versions --bucket mybucket --prefix dir/s --delimiter '/'
aws --endpoint-url http://localhost:4566 s3api list-object-versions --bucket mybucket --prefix dir/test --delimiter '/'
aws --endpoint-url http://localhost:4566 s3api list-object-versions --bucket mybucket --prefix dir/subdir --delimiter '/'
aws --endpoint-url http://localhost:4566 s3api list-object-versions --bucket mybucket --prefix dir/subdir/ --delimiter '/'
aws --endpoint-url http://localhost:4566 s3api list-object-versions --bucket mybucket --prefix dir/subdir/test2 --delimiter '/'

Environment

- OS: MacOS 11.6.1
- LocalStack: sha256:61dcd2dfc0b4c564f7df64b5fa09a152b3afcdde333fc03a7ab212ccfecb1591

Anything else?

No response

Metadata

Metadata

Assignees

Labels

aws:s3Amazon Simple Storage Servicestatus: resolved/fixedResolved with a fix or an implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions