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

The contents of boto3 s3 list_objects method returns the prefix as well as the list of objects inside the prefix. #4051

Closed
hzitoun-thefork opened this issue Mar 15, 2024 · 2 comments
Assignees
Labels
bug This issue is a confirmed bug. closed-for-staleness p2 This is a standard priority issue response-requested Waiting on additional information or feedback. s3

Comments

@hzitoun-thefork
Copy link

hzitoun-thefork commented Mar 15, 2024

Describe the bug

I have a folder with 3 files inside:

file1
file2
file3

Here is the code:

import boto3
bucket = 'bucket_name'
#Make sure you provide / in the end
prefix = 'my_prefix/'  

client = boto3.client('s3')
result = client.list_objects_v2(Bucket=bucket, Prefix=prefix, Delimiter='/')
for o in result.get('Contents'):
    print(o)

The result instead of:

my_prefix/file1
my_prefix/file2
my_prefix/file3

I got the prefix as 4th objects!!!

my_prefix/
my_prefix/file1
my_prefix/file2
my_prefix/file3

The same code works well for another prefix. The only difference is that my_prefix's storage class is DEEP_ARCHIVE.

Expected Behavior

3.9.4

Current Behavior

Explained up.

Reproduction Steps

code shared

Possible Solution

No response

Additional Information/Context

No response

SDK version used

3.9.4

Environment details (OS name and version, etc.)

macOS

@hzitoun-thefork hzitoun-thefork added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Mar 15, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK self-assigned this Apr 16, 2024
@RyanFitzSimmonsAK RyanFitzSimmonsAK added investigating This issue is being investigated and/or work is in progress to resolve the issue. s3 p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Apr 16, 2024
@RyanFitzSimmonsAK
Copy link
Contributor

Hi @hzitoun-thefork, thanks for reaching out. I was able to reproduce this behavior, but I'm not sure it's a bug. Folders in S3 are a 0-byte object, which matches the prefix you specified. It's pretty easy to remove the folder as a result with further scripting (comparing key, size, or file type all work). Could you clarify what you mean by the same code working for another prefix? Is the bucket formatted in the same way (bucket/folder/files) or is it structured differently? Thanks!

@RyanFitzSimmonsAK RyanFitzSimmonsAK added response-requested Waiting on additional information or feedback. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Apr 16, 2024
Copy link

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Apr 27, 2024
@github-actions github-actions bot closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a confirmed bug. closed-for-staleness p2 This is a standard priority issue response-requested Waiting on additional information or feedback. s3
Projects
None yet
Development

No branches or pull requests

2 participants