Skip to content

fix(parser,event_handler): accept the list values VPC Lattice V2 sends in headers and query strings - #8793

Merged
leandrodamascena merged 2 commits into
developfrom
fix/vpc-lattice-v2-list-values
Nov 10, 2026
Merged

leandrodamascena merged 2 commits into
developfrom
fix/vpc-lattice-v2-list-values

Conversation

@leandrodamascena

Copy link
Copy Markdown
Contributor

Issue number:
closes #8773
closes #8776

Summary

Changes

VPC Lattice sends every headers and queryStringParameters value in a V2 event as a list, even when there is one value. Two places in the library still assumed plain strings:

  • VpcLatticeV2Model typed both fields as dict[str, str], so the model and VpcLatticeV2Envelope rejected every real event with a ValidationError. Both are dict[str, list[str]] now, descriptions and examples updated. Strict list, no str union: the service never sends strings, and a union would push an isinstance check into every handler that reads a header.
  • OpenAPIRequestValidationMiddleware read Content-Type with .strip() in two places, so VPCLatticeV2Resolver(enable_validation=True) crashed with AttributeError: 'list' object has no attribute 'strip' on any route with a Body() or Form() parameter. A small _get_content_type helper takes the first element when the header is a list; the other resolvers keep passing strings through it unchanged.

Tests: the V2 parser tests now use vpcLatticeV2EventWithHeaders.json, which has the list shape, plus three new ones against vpcLatticeV2EventWithQueryString.json, the event captured from a live target group (#8572): model, envelope, and one asserting that the plain-string fixture is rejected. On the resolver side, three functional tests run validation on the captured event with a JSON body, a form body and an invalid body (422, not a crash). All ten fail on develop, pass here. No fixture was changed; vpcLatticeV2Event.json is still used by the data class and resolver tests, where the string shape does not matter.

Reported by @Manishram-ai (#8773, first fix in #8774) and @AtulJoshi1206 (#8776, #8777).

User experience

VpcLatticeV2Model and the envelope parse real V2 events, and header and query string values come back as lists, {"header1": ["value1", "value2"]}. Request validation works on VPCLatticeV2Resolver like on every other resolver.

Visible change: an event with plain string values for those fields, a shape VPC Lattice does not send, fails validation now. Hand-written test events with that shape need the list form.

Verification

tests/unit/parser, tests/unit/data_classes, tests/functional/event_handler, tests/functional/parser: 1719 passed. mypy clean on both packages, xenon within limits, ruff clean. The two list-valued fixtures came from a real VPC Lattice V2 target group, so the shape under test is the service's, not a mock. Written with an AI assistant; I ran everything above myself.


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

@leandrodamascena
leandrodamascena requested a review from a team as a code owner November 10, 2026 09:28
@leandrodamascena leandrodamascena added this to the 3.40.0 milestone Nov 10, 2026
@leandrodamascena leandrodamascena added bug Something isn't working event_handlers parser Parser (Pydantic) utility labels Nov 10, 2026
@boring-cyborg boring-cyborg Bot added the tests label Nov 10, 2026
@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 10, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.18%. Comparing base (94c8d72) to head (5d0477a).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8793   +/-   ##
========================================
  Coverage    97.18%   97.18%           
========================================
  Files          323      323           
  Lines        16537    16542    +5     
  Branches      1494     1495    +1     
========================================
+ Hits         16071    16076    +5     
  Misses         326      326           
  Partials       140      140           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leandrodamascena
leandrodamascena merged commit 93159ce into develop Nov 10, 2026
14 checks passed
@leandrodamascena
leandrodamascena deleted the fix/vpc-lattice-v2-list-values branch November 10, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working event_handlers parser Parser (Pydantic) utility size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tests

Projects

None yet

1 participant