Repository navigation
Retry transient 403s in custom authorizer missing-context integration tests - #2628
Merged
Merged
Conversation
The five *_WithMissingAuthorizerContextKey_ReturnsUnauthorized tests sent a single request with the partial-context token. A freshly deployed API Gateway stage can briefly return 403 on the authorizer path, which the valid-token tests already retry. The REST API variant failed intermittently in AWS CI with 403 instead of the expected 401. - Add GetWithTokenAsync to the fixture and use it for the partial-context requests, so they get the same 403 retry as the valid-token requests. - Add ResponseAssert.StatusCodeAsync, which includes the response body and the API Gateway error type and request ID headers when the status code does not match.
normj
marked this pull request as ready for review
December 1, 2026 20:28
dscpinheiro
approved these changes
Dec 1, 2026
afroz429
approved these changes
Dec 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes:
RestApiTests.RestUserInfo_WithMissingAuthorizerContextKey_ReturnsUnauthorizedfails intermittently in AWS CI withExpected: Unauthorized, Actual: Forbidden. It failed on runs for PRs that only changed docs (for example run 46496486705), and passed on re-run.The REST authorizer always returns an Allow policy for the
partial-contexttoken, and every authorizer hasAuthorizerResultTtlInSeconds: 0, so the 403 does not come from the authorizer or a cached result. The likely cause is the same one the suite already handles for the valid-token tests: a freshly deployed API Gateway stage can briefly return 403 on the authorizer path. The warm-up andGetWithValidTokenAsyncretry only cover thevalid-tokenrequests. The five missing-context-key tests sent a singlepartial-contextrequest with no retry, and only the REST variant (the slower stage to settle) failed.Changes:
GetWithTokenAsync(url, token)to the fixture.GetWithValidTokenAsyncnow delegates to it. The five*_WithMissingAuthorizerContextKey_ReturnsUnauthorizedtests use it, so their requests get the same 403 retry. A 403 is never the expected result for these tests, so the retry can't hide a regression: if the authorizer really denied the request, the retry times out and the test still fails.ResponseAssert.StatusCodeAsync. On a status mismatch, the failure message includes the response body and thex-amzn-ErrorType,x-amzn-RequestIdandx-amz-apigw-idheaders. If the test fails again, this shows whether the 403 came from the authorizer (an explicit-deny body) or from API Gateway before the authorizer ran.Test-only change, so no change file.
Validation: the integration test project builds with no new warnings. The tests need a deployed stack, so they will be exercised by AWS CI on this PR.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.