Skip to content

fix(s3): remove XML declaration from GetBucketLocation response#403

Merged
hectorvent merged 1 commit intofloci-io:mainfrom
ctnnguyen:fix/s3-get-bucket-location-xml-declaration
Apr 13, 2026
Merged

fix(s3): remove XML declaration from GetBucketLocation response#403
hectorvent merged 1 commit intofloci-io:mainfrom
ctnnguyen:fix/s3-get-bucket-location-xml-declaration

Conversation

@ctnnguyen
Copy link
Copy Markdown
Contributor

Summary

The GetBucketLocation response includes a <?xml version="1.0" encoding="UTF-8"?> declaration that AWS does not return. AWS SDK v2 uses a regex >(.+)<\/Location to parse this response, and the ?> in the XML declaration provides a > that the greedy .+ matches from, causing the SDK to capture garbage instead of the actual region value. This breaks tools like Serverless Framework that rely on SDK v2's parsed LocationConstraint for bucket region validation.

Also uses a self-closing <LocationConstraint ... /> element for us-east-1 buckets to exactly match the AWS wire format.

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

AWS Compatibility

Incorrect behavior: Response included <?xml version="1.0" encoding="UTF-8"?> prefix which AWS does not return for this API. This caused AWS SDK v2's regex-based parser to produce incorrect LocationConstraint values.

Correct behavior (AWS): Response body is just the <LocationConstraint> element with no XML declaration. For us-east-1, a self-closing <LocationConstraint xmlns="..."/>. For other regions, <LocationConstraint xmlns="...">region</LocationConstraint>.

Checklist

  • ./mvnw test passes locally
  • New or updated integration test added
  • Commit messages follow Conventional Commits

@ctnnguyen ctnnguyen marked this pull request as ready for review April 13, 2026 16:47
@fredpena fredpena added the s3 label Apr 13, 2026
@hectorvent
Copy link
Copy Markdown
Collaborator

Thanks @ctnnguyen

@hectorvent hectorvent merged commit 3621c32 into floci-io:main Apr 13, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants