Skip to content

fix(parser): accept API Gateway console test events without headers - #8852

Open
Manishram-ai wants to merge 1 commit into
aws-powertools:developfrom
Manishram-ai:fix/parser-apigw-console-test-headers
Open

Manishram-ai wants to merge 1 commit into
aws-powertools:developfrom
Manishram-ai:fix/parser-apigw-console-test-headers

Conversation

@Manishram-ai

Copy link
Copy Markdown
Contributor

Issue number:
closes #8849

Summary

Changes

  • APIGatewayProxyEventModel turns a null headers or multiValueHeaders into an empty dict before validating. The Test tab in the API Gateway console sends null for both when the test has no headers. ApiGatewayAuthorizerRequest inherits the same validator.
  • The field types stay dict, so handlers don't need a None check.
  • New event tests/events/apiGatewayProxyEventConsoleTest.json, the one captured from the Test tab in Feature Request: add APIGatewayRequestAuthorizerEventV2 schemas/envelopes powertools-lambda-typescript#2624 with the IAM user name replaced, and a test that parses it.

User experience

Today a REST API handler using APIGatewayProxyEventModel fails with a ValidationError when you test it from the console without headers, even though the parser already accepts the console's test-invoke-source-ip. With this change the event parses, and headers and multiValueHeaders are {}. Requests with headers parse the same as before.

Verification

  • The new test fails on develop with Input should be a valid dictionary for headers and multiValueHeaders, and passes with this change.
  • tests/unit/parser and tests/functional/parser: 273 passed on Python 3.10, 3.12 and 3.14.
  • ruff check, ruff format --check and mypy are clean, and tests/performance passes.
  • I didn't run a console test myself. The event is the one captured in the TypeScript issue, and APIGatewayRestResolver already returns 200 for it on develop.

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.

@Manishram-ai
Manishram-ai requested a review from a team as a code owner November 16, 2026 19:12
@Manishram-ai
Manishram-ai requested a review from hjgraca November 16, 2026 19:12
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 16, 2026
@boring-cyborg boring-cyborg Bot added the tests label Nov 16, 2026
@sonarqubecloud

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/M Denotes a PR that changes 30-99 lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: APIGatewayProxyEventModel rejects events from the API Gateway console's Test tab

1 participant