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

S3Client.listObjects always return an empty array #8

Closed
oleiade opened this issue Aug 30, 2022 · 2 comments · Fixed by #9
Closed

S3Client.listObjects always return an empty array #8

oleiade opened this issue Aug 30, 2022 · 2 comments · Fixed by #9
Assignees
Labels
bug Something isn't working

Comments

@oleiade
Copy link
Member

oleiade commented Aug 30, 2022

What

It's been reported that the S3Client.listObjects returns an empty Array. We were able to reproduce the issue and should work towards a better understanding of what happens and a fix.

const s3 = new S3Client(awsConfig)
const objects = s3.listObjects(existingBucketNameWithExistingObjects)
console.log(objects) // []

Considerations

Ideally, we should consider introducing end2end tests to assert we don't break these kinds of operations in the future. localstack has been mentioned many times and seems a good option. As the signature process has unit tests asserting its correctness, we probably can afford a solution that doesn't require any authentication.

How

Needs investigation

Definition of done

For a given bucket, containing N files, a user with the appropriate permissions should be able to retrieve an array of N objects by calling S3Client.listObjects on it.

@oleiade oleiade self-assigned this Aug 30, 2022
@oleiade oleiade added the bug Something isn't working label Aug 30, 2022
@oleiade oleiade added this to the 0.5.0 milestone Aug 30, 2022
@oleiade
Copy link
Member Author

oleiade commented Aug 30, 2022

Maybe as a result of my session token #5 not having enough rights?

@oleiade
Copy link
Member Author

oleiade commented Aug 30, 2022

Found what was causing the issue (my typescript noobness for the most part): list-type=2&prefix=${prefix}. As it turns out, prefix is an optional string parameter, I assumed that if not set it would hold an empty string (as optional types are a bit... atypical in TS). It would rather hold undefined.

Which would lead to the URL ending up looking like: https://test-jslib-aws.s3.us-east-1.amazonaws.com/?list-type=2&prefix=undefined, effectively asking AWS to send us back the list of objects prefixed with undefined. Not what we intended...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant