S3: False Request and 'Object Not Found' Error When Bucket Name Matches Object Key Prefix and usePathStyle is False #2605
Labels
bug
This issue is a bug.
closed-for-staleness
p2
This is a standard priority issue
response-requested
Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Acknowledgements
go get -u github.com/aws/aws-sdk-go-v2/...
)Describe the bug
We have a bucket named 'test' containing multiple objects under the path 'test/test/dir1/'. While listing the objects within this directory poses no issues, attempting to retrieve them results in an incorrect request and an Object Not Found error. This occurs when the usePathStyle parameter is set to false.
Expected Behavior
Retrieving objects from an S3 bucket where the bucket name matches the prefix of the object keys should succeed without errors.
Current Behavior
Attempting to retrieve an object results in the following error message:
Failed to get object from bucket: operation error S3: GetObject, HTTPS response error with StatusCode: 404
.Reproduction Steps
Bucket name = test
Full path to object = test/test/dir1/object1
usePathStyle = false
Possible Solution
No response
Additional Information/Context
service/s3/internal/customizations/update_endpoint.go:238
removeBucketFromPath is removing the prefix of our object key which results in a request like 'https://test.[aws domain]/dir1/object1' instead of 'https://test.[aws domain]/test/dir1/object1'
AWS Go SDK V2 Module Versions Used
github.com/aws/aws-sdk-go-v2/service/s3 v1.48.1
Compiler and Version used
go version go1.21.4 linux/amd64
Operating System and version
6.8.4-arch1-1
The text was updated successfully, but these errors were encountered: