Skip to content

Bug: VpcLatticeV2Model and VpcLatticeV2Envelope reject every real VPC Lattice V2 event #8777

Closed as not planned

Description

@AtulJoshi1206

Expected Behaviour

VpcLatticeV2Model and VpcLatticeV2Envelope should parse the events VPC Lattice sends to a target group that uses the V2 event structure.

Current Behaviour

VPC Lattice V2 sends every value in headers and queryStringParameters as a list of strings, even single values. That's in the V2 event structure and in the event captured from a live V2 target group.

VpcLatticeV2Model types both fields as dict[str, str], so the model and the envelope fail on every real event. The captured event gives 7 validation errors. The repo fixture vpcLatticeV2Event.json uses plain strings, which is why the existing tests pass.

The TypeScript library fixed the same schema in aws-powertools/powertools-lambda-typescript#5764 and aws-powertools/powertools-lambda-typescript#5773.

Code snippet

from pydantic import BaseModel

from aws_lambda_powertools.utilities.parser import envelopes, parse
from tests.functional.utils import load_event

# Event captured from a live VPC Lattice V2 target group
event = load_event("vpcLatticeV2EventWithQueryString.json")


class Hello(BaseModel):
    hello: str


print(parse(event=event, model=Hello, envelope=envelopes.VpcLatticeV2Envelope))
# ValidationError: 7 validation errors for VpcLatticeV2Model
# headers.x-amzn-requestid
#   Input should be a valid string [type=string_type, input_value=['6ccfc913-...'], input_type=list]
# (same for headers.content-type, x-forwarded-for, header1, host,
#  queryStringParameters.QS1 and queryStringParameters.single)

Possible Solution

Type both fields as dict[str, list[str] | str]. A strict list[str], as TypeScript did, would start rejecting events with plain string values (the docs sample payloads, vpcLatticeV2Event.json, hand-written test events), and those parse today (ADR 0006). Accepting both fixes real events and keeps the old ones working. I have a fix with tests ready and can open a PR once this is triaged.

Steps to Reproduce

Run the snippet above from the repo root on develop.

Did you run the reproduction yourself?

Yes, I ran it and saw the failure

Powertools for AWS Lambda (Python) version

3.38.0

AWS Lambda function runtime

3.12

Packaging format used

PyPi

Debugging logs

No response

Activity

  1. blacksoxx commented on Nov 7, 2026

    @blacksoxx

    This looks like the same bug as #8773, which has a fix open in #8774 (both fields typed as dict[str, list[str]], the same shape the TypeScript fix used).

  2. leandrodamascena commented on Nov 10, 2026

    @leandrodamascena
    Contributor

    Same bug as #8773, which is already in 3.40.0. Thanks for the list[str] | str argument; I thought about it and I am going strict, the service never sends plain strings and the union would leak into everyone's handler code. Closing as duplicate, keep #8776 open, that one is separate and real.

  3. powertools-for-aws-oss-automation commented on Nov 10, 2026

    @powertools-for-aws-oss-automation

    Warning

    This issue is now closed. Please be mindful that future comments are hard for our team to see.
    If you need more assistance, please either reopen the issue, or open a new issue referencing this one.
    If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions