Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

listObjectsV2 returns different structure between v3.242.1 … v3.243.0 #2559

Closed
leevigraham opened this issue Nov 15, 2022 · 9 comments
Closed
Assignees
Labels
bug This issue is a bug.

Comments

@leevigraham
Copy link

Describe the bug

Run the following php code

$command = $client->getCommand(
    'ListObjectsV2',
    [
        'Bucket'  => $bucket,
        'Prefix'  => $prefix,
        'MaxKeys' => 1,
    ]
);

$result = $client->executeCommand($command);

Expected Behavior

v3.242.1 does not include contents

Screen Shot 2022-11-15 at 3 40 49 pm

3.243.0 does include contents with size: 0

Screen Shot 2022-11-15 at 3 40 11 pm

Current Behavior

See Expected Behavior

Reproduction Steps

See "Describe the bug"

Possible Solution

No response

Additional Information/Context

This causes issues downstream in thephpleague/flysystem: https://github.com/thephpleague/flysystem/blob/3.x/src/AwsS3V3/AwsS3V3Adapter.php#L132

SDK version used

3.243.0

Environment details (Version of PHP (php -v)? OS name and version, etc.)

php 8.1

@i-just
Copy link

i-just commented Nov 15, 2022

I believe this is happening because of ill-formatted endpoint URL. You can see it in the $results if you follow @leevigraham's steps.

On v3.242.1 src/AwsS3Adapter.php->doesDirectoryExist(), the $result > @metadata > effectiveUri is correctly encoded, on v3.243.0 and v3.243.1 it's not. It causes the v3.243.1 doesDirectoryExist() to check if there's any directory in the bucket you're searching through, ignoring the prefix param.

v3.242.1: https://s3.amazonaws.com/<bucket_name>?list-type=2&prefix=300C.png%2F&max-keys=1
v3.243.0, v3.243.1: https://s3.amazonaws.com/<bucket_name>?list-type=2%3Dprefix=300C.png%2F&max-keys=1

@lro-tiierisch
Copy link

Hey, I just created a new PHP project on my local machine and installed the AWS PHP SDK because I had to look up some files in our companies S3 storage. After getting some unexpected results I also noticed that the Prefix parameter seems to be ignored in v3.243.

@stobrien89
Copy link
Member

Hi all,

I've created a PR which addresses both this issue and #2558. We should have a release cut shortly. Many apologies for the disruption here.

@i-just
Copy link

i-just commented Nov 15, 2022

Thanks. I'll close my PR in that case.

@stobrien89
Copy link
Member

Version 3.243.2 is live— can those affected upgrade and confirm this is no longer an issue? Thanks!

@lro-tiierisch
Copy link

The Prefix parameter seems to be working again with this fix. Thanks

@stobrien89 stobrien89 self-assigned this Nov 15, 2022
@stobrien89 stobrien89 removed the needs-triage This issue or PR still needs to be triaged. label Nov 15, 2022
@stobrien89
Copy link
Member

Closing this now, but more than happy to take another look if anyone is still having issues.

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@drekinov
Copy link

drekinov commented Nov 21, 2022

We had that issue too.
I am writing to share how bad it could be.
We have temporary files which are deleted after some time. (laravel + flysystem)
Because of that issue this lead to batch delete API query to root of bucket.
effectively we had one of dev buckets wiped.

Fortunately that did not land on stage or production because it wipe files as fast as blink of the eye.
It took me couple days to debug that because i thought it is bad code on our side :) (which probably is still true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants