Skip to content

fix(parser): accept multi-value headers in VPC Lattice v2 events - #5773

Merged
dreamorosi merged 1 commit into
aws-powertools:mainfrom
vishwakt:fix/5764-parser-vpc-lattice-v2-multi-value
Oct 3, 2026
Merged

dreamorosi merged 1 commit into
aws-powertools:mainfrom
vishwakt:fix/5764-parser-vpc-lattice-v2-multi-value

Conversation

@vishwakt

@vishwakt vishwakt commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Summary

VPC Lattice sends every header and query string value in a V2 event as an array of strings, even when there is a single value, but VpcLatticeV2Schema typed both as records of strings. Every real V2 event failed to parse, so VpcLatticeV2Envelope could not parse any event. This types both fields as arrays and keeps the top-level requestId.

Changes

  • Changed headers and queryStringParameters in packages/parser/src/schemas/vpc-latticev2.ts to z.record(z.string(), z.array(z.string())).
  • Declared the top-level requestId as an optional string, so it is no longer stripped.
  • Replaced packages/parser/tests/events/vpc-lattice-v2/base.json with the event captured from a live V2 target group in the issue. The existing round-trip test in the schema tests now covers single and repeated values and requestId, and fails against the schema on main.
  • Updated the envelope tests to the captured event's body and set the binary test's content-type header as an array.
  • Updated the JSDoc example to the captured shape.
  • Left the identity field casing (principalOrgID, x509SubjectCn and similar) unchanged, since it needs a live event with IAM auth or Roles Anywhere to confirm.

This changes the inferred VpcLatticeEventV2 type for headers and queryStringParameters. Since no real event could pass the previous schema, no working code can depend on the old shape.

Issue number: closes #5764


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.

VPC Lattice sends every header and query string value in a V2 event as an array of strings, even a single value, but VpcLatticeV2Schema typed both as records of strings, so every real event failed to parse and VpcLatticeV2Envelope could not parse any event. Type both as records of string arrays and declare the top-level requestId, which was stripped.

Replace the hand-written fixture with an event captured from a live V2 target group, so the existing round-trip test covers the real shape, and update the envelope tests to its body.

Closes aws-powertools#5764

@dreamorosi dreamorosi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@dreamorosi
dreamorosi merged commit 40fb84e into aws-powertools:main Oct 3, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M PR between 30-99 LOC

2 participants