Skip to content

fix(parser): keep query strings in APIGatewayWebSocketConnectEventModel - #8864

Open
Manishram-ai wants to merge 1 commit into
aws-powertools:developfrom
Manishram-ai:fix/parser-websocket-connect-query-strings
Open

Manishram-ai wants to merge 1 commit into
aws-powertools:developfrom
Manishram-ai:fix/parser-websocket-connect-query-strings

Conversation

@Manishram-ai

Copy link
Copy Markdown
Contributor

Issue number:
closes #8862

Summary

Changes

  • APIGatewayWebSocketConnectEventModel now has query_string_parameters and multi_value_query_string_parameters, read from queryStringParameters and multiValueQueryStringParameters. Both default to None, so connections without a query string parse the same as before.
  • Two new tests. One parses apiGatewayWebSocketApiConnect.json and checks both fields, and the other removes them from the event and checks they come back as None.
  • I left APIGatewayWebSocketDisconnectEventModel alone. Its test event has query strings, but I couldn't find anything showing $disconnect events carry them.

User experience

Before, the query string of a $connect request, such as a token or a user ID, was dropped, so a handler using the model couldn't read it. Now parsed.query_string_parameters returns {'userId': 'user123', 'token': 'abc.def.ghi'} for the repo's connect event. Events without a query string parse as before, and no existing field changes.

Verification

  • Both new tests fail on develop, where the model has no query_string_parameters, and pass with this change.
  • tests/unit/parser and tests/functional/parser: 274 passed on Python 3.10, 3.12 and 3.14 (272 on develop).
  • tests/unit: 703 passed, 1 skipped. tests/performance passes.
  • ruff format --check, ruff check and mypy aws_lambda_powertools examples are clean.
  • I didn't deploy a WebSocket API. The field names come from the $connect example in the API Gateway docs, the connect event in tests/events, and the WebSocket authorizer event in tests/events, which has the same two fields.

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 17, 2026 03:51
@Manishram-ai
Manishram-ai requested a review from hjgraca November 17, 2026 03:51
@boring-cyborg boring-cyborg Bot added the tests label Nov 17, 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 Nov 17, 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/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: APIGatewayWebSocketConnectEventModel drops the query string parameters

1 participant