-
Notifications
You must be signed in to change notification settings - Fork 4.3k
fix(amplify-alpha): handle empty customResponseHeaders array #35700
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
Conversation
- Add null check for empty custom response headers array in App constructor - Update renderCustomResponseHeaders function to handle empty array case - Add test case for empty custom response headers array - Prevent rendering of CustomHeaders when array is empty - Improve null/undefined handling for custom response headers configuration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter fails with the following errors:
❌ Fixes must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
✅ A exemption request has been requested. Please wait for a maintainer's review.
|
Exemption Request this PR is essentially improving the check and having a unit test covered. |
- Enhance `renderCustomResponseHeaders` function to handle empty headers array more robustly - Add defensive error throwing for internal edge case scenarios - Update test case to validate empty custom headers array handling - Improve error messaging and internal documentation for header rendering method - Ensure consistent behavior when no custom headers are provided Resolves aws#35693 by preventing potential runtime errors and improving error handling in Amplify App configuration.
- Replace generic Error with custom ValidationError in renderCustomResponseHeaders - Add explicit error scope to improve error tracing and debugging - Maintain existing validation logic for empty custom headers array - Enhance error message specificity for internal CDK validation
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #35693.
Reason for this change
The
amplify.Appconstruct fails with a TypeError whencustomResponseHeadersis an empty array, preventing CDK synthesis. This is a regression introduced in v2.202.0 (PR #31771) that breaks applications passing an empty array to this property.Description of changes
Added defensive checks to prevent array access on empty
customResponseHeadersarrays:CustomHeadersproperty is properly omitted (undefined)renderCustomResponseHeadersfunction (line 608-611): Throws clear error if function is called with empty array, catching potential CDK programming bugsThe fix follows CDK defensive programming patterns with a clear separation of concerns:
Description of how you validated changes
CustomHeadersproperty is correctly absent. All 45 unit tests pass (100%).integ.app-monorepo-custom-headerstest specifically validates custom headers behavior remains correct.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license