Repository navigation
fix(event_handler): route VPC Lattice requests that carry a query string - #8572
Merged
leandrodamascena merged 2 commits intoOct 17, 2026
Conversation
VPC Lattice sends the query string inside the request path (V1 raw_path, V2 path) as well as parsed. VPCLatticeEvent.path and VPCLatticeEventV2.path returned that value verbatim, so a request like /echo?QS1=value1 never matched the anchored route for /echo and got a 404 on both resolvers. The same value broke strip_prefixes and Swagger's ?format=json. Strip the query in the data classes so path is the URL path without the query string, as for the other BaseProxyEvent sources. Split on the first "?" (RFC 3986), so an encoded %3F stays in the path. V1 raw_path and the raw event keep the original value.
leandrodamascena
approved these changes
Oct 17, 2026
leandrodamascena
left a comment
Contributor
There was a problem hiding this comment.
Thanks! I reproduced the 404 with the V2 event from the TS issue and it passes with this fix. AWS docs confirm the path carries the query string in both versions, so this is correct. Approving.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8572 +/- ##
========================================
Coverage 96.93% 96.93%
========================================
Files 318 318
Lines 15999 16002 +3
Branches 1419 1419
========================================
+ Hits 15508 15511 +3
Misses 349 349
Partials 142 142 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
leandrodamascena
merged commit Oct 17, 2026
93e577c
into
aws-powertools:develop
13 of 14 checks passed
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.



Issue number: closes #8571
Summary
Changes
VPC Lattice puts the query string inside the request path (
raw_pathin V1,pathin V2) and also sends it parsed.VPCLatticeEvent.pathandVPCLatticeEventV2.pathreturned that value verbatim, and the resolvers match routes againstevent.pathwith anchored regexes. So any request with a query string got a 404 onVPCLatticeResolverandVPCLatticeV2Resolver, sync and async.This makes
paththe URL path without the query string, as it is for REST API, HTTP API, Function URL and ALB events.VPCLatticeEvent.pathreturnsraw_pathup to the first?.raw_pathitself is unchanged, and its docstring now says it includes the query string.VPCLatticeEventV2gets its ownpathproperty, returningpathup to the first?. The original value stays inevent.raw_event["path"].?starts the query, so an encoded%3Fstays in the path.pathfeeds routing,strip_prefixes, Swagger UI's?format=jsonand user code, so fixing it there gives all of them the corrected value.tests/events/vpcLatticeV2EventWithQueryString.jsonis the event captured from a live V2 target group in Bug: VpcLatticeV2Schema rejects every real V2 event powertools-lambda-typescript#5764, unchanged. It's the same fixture TypeScript merged in chore(ci): new pre-release 3.3.1a21 #5773.tests/events/vpcLatticeEventWithQueryString.jsonisvpcLatticeEvent.jsonwith the query string inraw_path, as the AWS docs show for V1.developand pass with this change:pathexclude the query string, and V1raw_pathkeeps it.?inside the query, and an encoded%3Fin the path.test_vpc_lattice_eventnow also checks that a path without a query is unchanged./orders/<order_id>with/orders/42?expand=itemsgivesorder_id == "42".resolve_asyncis covered.enable_validation=TrueandAnnotated[int, Query(alias="order-id")].Checks:
ruff checkandruff format --check: clean.mypyonvpc_lattice.py: clean.Evidence that VPC Lattice sends the query string in the path:
"raw_path": "/path/to/resource?query1=value1&query2=value2"."path": "/?query1=value1&query2=value2", "The path of the request from the client that includes query string parameters.""raw_path": "/points?action=add".path: '/echo?QS1=value1&QS1=value2&single=one'.User experience
Before, for the V2 event captured in powertools-lambda-typescript#5764:
After: the request reaches
echoand returns 200 with{"query": {"QS1": "value1,value2", "single": "one"}}, andapp.current_event.path == "/echo". Dynamic routes,strip_prefixesand/swagger?format=jsonnow match the same way, and V1 behaves the same.Risk:
event.pathno longer contains the query string.event.pathshould useevent.query_string_parameters, or the raw value:event.raw_path(V1) orevent.raw_event["path"](V2).event.pathdirectly: data-class users (@event_source(data_class=VPCLatticeEvent)/VPCLatticeEventV2), catch-all routes,not_foundhandlers and middlewares.Follow-ups (not in this PR). These have a different root cause: V2 sends every header and query string value as a list.
aws_lambda_powertools/event_handler/middlewares/openapi_validation.py:144calls.strip()onheaders.get("content-type", ""), which is a list for V2. Withenable_validation=Trueand a body parameter, a real V2 event fails withAttributeError: 'list' object has no attribute 'strip'.VpcLatticeV2ModeldeclaresheadersandqueryStringParametersasdict[str, str], so the parser rejects real V2 events. TypeScript fixed the same schema in powertools-lambda-typescript#5764 and chore(ci): new pre-release 3.3.1a21 #5773.examples/event_handler_rest/src/getting_started_vpclattice*_resolver.json,examples/event_sources/events/vpc_lattice*_payload.json) also leave the query string out of the path.AI assistance: prepared with Claude Code; the change was reviewed and the tests were run locally.
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.
🤖 Generated with Claude Code