Skip to content

fix(parser): accept multi-value headers and query strings in VPC Lattice v2 events - #8774

Open
Manishram-ai wants to merge 1 commit into
aws-powertools:developfrom
Manishram-ai:fix/parser-vpc-lattice-v2-multivalue-headers
Open

Manishram-ai wants to merge 1 commit into
aws-powertools:developfrom
Manishram-ai:fix/parser-vpc-lattice-v2-multivalue-headers

Conversation

@Manishram-ai

Copy link
Copy Markdown
Contributor

Issue number:
closes #8773

Summary

Changes

  • headers and query_string_parameters in VpcLatticeV2Model are now dict[str, list[str]]. VPC Lattice sends every header and query string value in a V2 event as a list, even a single one (docs). I updated the field descriptions and examples to match.
  • The V2 parser tests used vpcLatticeV2Event.json, which has plain string values that VPC Lattice doesn't send. They now use vpcLatticeV2EventWithHeaders.json, which has the same request context with list values. I didn't change any fixtures, since other tests still use vpcLatticeV2Event.json.
  • Two new tests parse the event captured from a live V2 target group (vpcLatticeV2EventWithQueryString.json), once with the model and once through VpcLatticeV2Envelope.

This is the same fix as aws-powertools/powertools-lambda-typescript#5773.

User experience

Before, every real V2 event failed with a ValidationError, so VpcLatticeV2Model and VpcLatticeV2Envelope couldn't be used with VPC Lattice. Now they parse, and the values come back as lists, like {"header1": ["value1", "value2"]}.

Events with plain string values, like the old test fixture, fail validation now. VPC Lattice never sends that shape, so I treated this as a fix to match the AWS contract (ADR 0006). If you'd rather keep accepting strings with a PowertoolsUserWarning until the next major, I'm happy to change it.

Verification

  • With the model on develop, 6 of the 7 tests in tests/unit/parser/_pydantic/test_vpc_latticev2.py fail: the 4 existing tests that now use list values and the 2 new ones. All 7 pass with this change.
  • tests/unit/parser, tests/unit/data_classes/required_dependencies, tests/functional/parser and tests/functional/event_handler: 1701 passed, 1 skipped (Python 3.12).
  • ruff format --check, ruff check and mypy are clean on the changed files.
  • I didn't set up a VPC Lattice target group. The event shape comes from the VPC Lattice docs and the event captured from a live V2 target group in Bug: VpcLatticeV2Schema rejects every real V2 event powertools-lambda-typescript#5764, which is already in tests/events.

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.

…ice v2 events

VPC Lattice sends every header and query string value in a V2 event as a
list, even when there is only one value. VpcLatticeV2Model typed both
fields as dict[str, str], so every real V2 event failed validation and
VpcLatticeV2Envelope could not parse any of them.

Type both fields as dict[str, list[str]], matching the V2 event structure
in the VPC Lattice docs and the TypeScript parser. The parser tests now
use the list-shaped fixtures, plus the event captured from a live V2
target group.
@Manishram-ai
Manishram-ai requested a review from a team as a code owner November 5, 2026 01:58
@Manishram-ai
Manishram-ai requested a review from hjgraca November 5, 2026 01:58
@boring-cyborg boring-cyborg Bot added the tests label Nov 5, 2026
@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 5, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 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/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: VPC Lattice v2 parser model rejects real events because headers and query strings are lists

1 participant