Skip to content

Bug: Upgrade to 3.7.0 breaks List response validation in APIGatewayRestResolver #6216

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

Closed
alnemo opened this issue Mar 4, 2025 · 4 comments · Fixed by #6234
Closed

Bug: Upgrade to 3.7.0 breaks List response validation in APIGatewayRestResolver #6216

alnemo opened this issue Mar 4, 2025 · 4 comments · Fixed by #6234
Assignees
Labels
bug Something isn't working event_handlers

Comments

@alnemo
Copy link

alnemo commented Mar 4, 2025

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

@alnemo alnemo added bug Something isn't working triage Pending triage from maintainers labels Mar 4, 2025
@leandrodamascena
Copy link
Contributor

Hi @alnemo! Thank you so much for raising this issue! This PR introduced this unexpected regression. I see we don't have a test for it and that's why we didn't catch it before the merge.

We have a release scheduled for this Friday 07/03/2025 and I will revert this PR or fix this bug in this situation. Can you wait until then and adopt 3.8.0?

I'm really sorry about that.

@leandrodamascena
Copy link
Contributor

Closed via #6234

@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (Python) Mar 7, 2025
Copy link
Contributor

github-actions bot commented Mar 7, 2025

⚠️COMMENT VISIBILITY 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 tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release Fix or implementation already in dev waiting to be released label Mar 7, 2025
@leandrodamascena leandrodamascena moved this from Coming soon to Shipped in Powertools for AWS Lambda (Python) Mar 7, 2025
Copy link
Contributor

This is now released under 3.9.0 version!

@github-actions github-actions bot removed the pending-release Fix or implementation already in dev waiting to be released label Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working event_handlers
Projects
Status: Shipped
2 participants