-
Notifications
You must be signed in to change notification settings - Fork 420
Bug: Event Handler Data Validation KeyError: 'multiValueHeaders'
regression when running locally
#3823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Important This only happens locally or outside Lambda, and when Data Validation feature is used Reported on Discord -- agreed with customer to work on a fix and make a patch release tomorrow, as it blocks customers from upgrading as unit tests are failing. Our tests don't fail because Todo:
functional test def test_validate_with_minimal_event():
# GIVEN an APIGatewayRestResolver with validation enabled
app = APIGatewayRestResolver(enable_validation=True)
# WHEN a handler is defined with a default scalar parameter
@app.get("/users/<user_id>")
def handler(user_id: int = 123):
print(user_id)
minimal_event = {
"path": "/users/123",
"httpMethod": "GET",
"requestContext": {"requestId": "227b78aa-779d-47d4-a48e-ce62120393b8"}, # correlation ID
}
# THEN the handler should be invoked and return 200
result = app(minimal_event, {})
assert result["statusCode"] == 200 |
|
This is now released under 2.34.1 version! |
Expected Behaviour
Work as expected and described in the docs: https://docs.powertools.aws.dev/lambda/python/2.34.0/core/event_handler/api_gateway/#testing-your-code
Current Behaviour
When running locally, request fails when
multiValueHeaders
key isn't present despite not needing it.Code snippet
Possible Solution
Use
.get
over Key for a more defensive programming. Accidental regression was introduced in 2.33.0https://github.com/aws-powertools/powertools-lambda-python/pull/3687/files#diff-4188087d42ec470125206481864423dbc79a7d50ece2a5338b4be75e9cbf63a9R49
Steps to Reproduce
todo_api/app.py
with the contents earlierblah.py
) that will be run locally with the following contentsUncomment either line
multiValueHeaders
and the problem will go away.Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.8
Packaging format used
Lambda Layers
Debugging logs
No response
The text was updated successfully, but these errors were encountered: