Closed
Description
Expected Behaviour
3.6.0 and 3.7.0 behave the same
Current Behaviour
With powertools update to 3.7.0 same code returns 422 validation error, while it works on 3.6.0
Code snippet
from aws_lambda_powertools.event_handler import APIGatewayRestResolver, Response
import json
from pydantic import BaseModel
from typing import List
app = APIGatewayRestResolver(enable_validation=True)
class StatusGroup(BaseModel):
count: int
status: str
def lambda_handler(event, context):
return app.resolve(event,context)
@app.get("/status",
summary="status",
description="count",
response_description="status count",
responses={
200: {"description": "status count"}
}
)
def status( requests:List[str]) -> List[StatusGroup]:
response = [{"status":"initial","count":1},{"status":"done","count":1}]
return Response(200, body=json.dumps(response))
def main():
event = {
"path": "/status",
"httpMethod": "GET",
"requestContext": {"requestId": "227b78aa-779d-47d4-a48e-ce62120393b8"},
"body": '["1","2","3"]'
}
response = lambda_handler(event,None)
print(json.dumps(response,sort_keys=True, indent=4, default=str))
if __name__ == "__main__":
main()
Possible Solution
No response
Steps to Reproduce
Run the example code while 3.6.0 or below is installed
pip install --upgrade aws-lambda-powertools==3.6.0
Response is
{
"body": "[{"status": "initial", "count": 1}, {"status": "done", "count": 1}]",
"isBase64Encoded": false,
"multiValueHeaders": {},
"statusCode": 200
}
Upgrade to 3.7.0
pip install --upgrade aws-lambda-powertools==3.7.0
Response is now
{
"body": "{"statusCode":422,"detail":[{"loc":["response"],"type":"list_type"}]}",
"isBase64Encoded": false,
"multiValueHeaders": {
"Content-Type": [
"application/json"
]
},
"statusCode": 422
}
Powertools for AWS Lambda (Python) version
3.7.0
AWS Lambda function runtime
3.12
Packaging format used
PyPi
Debugging logs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Shipped