Skip to content

Bug: VPCLatticeV2Resolver with enable_validation fails on every request body (AttributeError: 'list' object has no attribute 'strip') #8776

Closed

Description

@AtulJoshi1206

Expected Behaviour

With enable_validation=True, a VPCLatticeV2Resolver route that takes a body parameter (Body(), Form() or a Pydantic model) should parse and validate the request body, the same as the other resolvers do.

Current Behaviour

VPC Lattice V2 sends every header value as a list, for example "content-type": ["application/json"]. OpenAPIRequestValidationMiddleware reads Content-Type as a string in two places:

  • _get_body calls app.current_event.headers.get("content-type", "").strip()
  • handler passes the same value to _is_form_content_type, which also calls .strip()

On a real V2 event both get a list, so every request to a route with a body parameter fails with AttributeError: 'list' object has no attribute 'strip' before it reaches the handler.

Header, query and cookie parameters, CORS and compression already handle list values. Only these two Content-Type reads don't.

Code snippet

from typing import Annotated

from pydantic import BaseModel

from aws_lambda_powertools.event_handler import VPCLatticeV2Resolver
from aws_lambda_powertools.event_handler.openapi.params import Body
from tests.functional.utils import load_event

# Event captured from a live VPC Lattice V2 target group
event = load_event("vpcLatticeV2EventWithQueryString.json")
print("content-type as VPC Lattice V2 sends it:", event["headers"]["content-type"])


class Item(BaseModel):
    hello: str


app = VPCLatticeV2Resolver(enable_validation=True)


@app.post("/echo")
def echo(item: Annotated[Item, Body()]):
    return item.model_dump()


print(app.resolve(event, {}))
# AttributeError: 'list' object has no attribute 'strip'
#   openapi_validation.py:144  content_type = app.current_event.headers.get("content-type", "").strip()

Possible Solution

Read Content-Type through a small helper that joins a list value into a string, and use it in both places. The other resolvers always pass a string there, so nothing changes for them. I have a fix with tests ready and can open a PR once this is triaged.

Steps to Reproduce

  1. Check out develop and run the snippet above from the repo root.
  2. The fixture tests/events/vpcLatticeV2EventWithQueryString.json is the event captured from a live V2 target group in Bug: VpcLatticeV2Schema rejects every real V2 event powertools-lambda-typescript#5764.
  3. A Form() body fails the same way, at the _is_form_content_type call.

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. leandrodamascena commented on Nov 10, 2026

    @leandrodamascena
    Contributor

    Confirmed, separate from the parser bug. Content-Type is read as a string in two places of the validation middleware and nothing else in the resolver has that gap. I know you have a fix ready and I appreciate that you waited for triage. Since it needs to land with #8773 in 3.40.0 this week, I am going to do both in one go. You get the reporter credit in the release notes.

  2. added this to the 3.40.0 milestone on Nov 10, 2026
  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.

  4. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    This is now released under 3.40.0 version!

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

Metadata

Metadata

Labels

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions