Skip to content

fix(data_classes): keep the ARN partition in authorizer from_route_arn - #8947

Open
THEpranavsomalraju wants to merge 1 commit into
aws-powertools:developfrom
THEpranavsomalraju:fix-authorizer-from-route-arn-partition
Open

THEpranavsomalraju wants to merge 1 commit into
aws-powertools:developfrom
THEpranavsomalraju:fix-authorizer-from-route-arn-partition

Conversation

@THEpranavsomalraju

Copy link
Copy Markdown

Issue number: closes #8946

Summary

Changes

APIGatewayAuthorizerResponse.from_route_arn and APIGatewayAuthorizerResponseWebSocket.from_route_arn now pass partition=parsed_arn.partition to the constructor. parse_api_gateway_arn already returned the partition and the constructor already accepted it; the two factories dropped it, so every response was built with the default "aws".

User experience

Before: an authorizer in aws-cn or aws-us-gov that builds its response with from_route_arn(event.method_arn, ...) returns a policy whose resources start with arn:aws:execute-api:, which is not the ARN API Gateway invoked.

After: the policy resources keep the partition of the incoming ARN, e.g. arn:aws-cn:execute-api:cn-north-1:.... Nothing changes for the aws partition.

Verification

Added a parametrized test for aws, aws-cn and aws-us-gov to each of the REST and WebSocket authorizer test files. The four non-commercial cases fail on develop and pass with the change; the rest of tests/unit/data_classes/required_dependencies passes (221 tests). No existing test was modified.

I have not validated this against a live API Gateway in aws-cn or GovCloud, since I don't have an account in those partitions. What I verified is the ARN in the returned policy document.

An AI assistant was used to help find this bug and write the change and tests.


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

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

parse_api_gateway_arn returns the partition, but both from_route_arn
factories dropped it, so the response was built with the default
"aws". An authorizer in aws-cn or aws-us-gov returned a policy for
arn:aws:execute-api, which is not the ARN API Gateway invoked.
@boring-cyborg

boring-cyborg Bot commented Dec 2, 2026

Copy link
Copy Markdown

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@boring-cyborg boring-cyborg Bot added the tests label Dec 2, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Dec 2, 2026
@sonarqubecloud

sonarqubecloud Bot commented Dec 2, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: APIGatewayAuthorizerResponse.from_route_arn drops the ARN partition (aws-cn, aws-us-gov)

1 participant