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

chore(middleware-sdk-s3): add status code 400 for S3 region redirects #6572

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

siddsriv
Copy link
Contributor

@siddsriv siddsriv commented Oct 17, 2024

Issue

Internal JS-5479

Description

Adds status code 400 in conjunction with the error code IllegalLocationConstraintException to also redirect regions for S3, if followRegionRedirects flag is set.

Testing

  • unit test
 PASS  src/validate-bucket-name.spec.ts (8.169 s)
 PASS  src/region-redirect-middleware.spec.ts (8.441 s)
 PASS  src/s3-express/functions/s3ExpressMiddleware.spec.ts
 PASS  src/s3-express/classes/S3ExpressIdentityCacheEntry.spec.ts
 PASS  src/s3-express/classes/S3ExpressIdentityCache.spec.ts (8.34 s)
 PASS  src/s3-express/classes/SignatureV4S3Express.spec.ts (8.549 s)

Test Suites: 9 passed, 9 total
Tests:       24 passed, 24 total
Snapshots:   0 total
Time:        8.999 s, estimated 10 s
Ran all test suites.
Done in 9.52s.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@siddsriv siddsriv requested a review from a team as a code owner October 17, 2024 01:46
if (
err?.$metadata?.httpStatusCode === 301 ||
// err.name === "PermanentRedirect" && --> removing the error name check, as that allows for HEAD operations (which have the 301 status code, but not the same error name) to be covered for region redirection as well
(err?.$metadata?.httpStatusCode === 400 && err?.name === "IllegalLocationConstraintException")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Successfully merging this pull request may close these issues.

1 participant