You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: VPCLatticeV2Resolver with enable_validation fails on every request body (AttributeError: 'list' object has no attribute 'strip') #8776
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:
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
fromtypingimportAnnotatedfrompydanticimportBaseModelfromaws_lambda_powertools.event_handlerimportVPCLatticeV2Resolverfromaws_lambda_powertools.event_handler.openapi.paramsimportBodyfromtests.functional.utilsimportload_event# Event captured from a live VPC Lattice V2 target groupevent=load_event("vpcLatticeV2EventWithQueryString.json")
print("content-type as VPC Lattice V2 sends it:", event["headers"]["content-type"])
classItem(BaseModel):
hello: strapp=VPCLatticeV2Resolver(enable_validation=True)
@app.post("/echo")defecho(item: Annotated[Item, Body()]):
returnitem.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
Check out develop and run the snippet above from the repo root.
Activity