Skip to content

Bug: the validation failure response might expose too much data #3405

Closed
@rubenfonseca

Description

@rubenfonseca

Expected Behaviour

Only the necessary data to be returned, including the name of the field that failed validation and the kind of error.

Current Behaviour

When a data validation error occurs, we can expose data that might not be wanted. This includes class names, file names, or simply the fact that pydantic and python is being used.

Code snippet

app = APIGatewayHttpResolver()

@app.get("/claims")
def claims() -> Dict[str, Any]:
    return "oh no, this is not a dict"  # type: ignore

Possible Solution

Return a subset of the information, while still allowing the customer to customize the payload using the global exception handler

Steps to Reproduce

Use the snippet above, and see the returned message when the API call is invoked.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.7

Packaging format used

PyPi

Debugging logs

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingevent_sourcesEvent Source Data Class utility

Type

No type

Projects

Status

Shipped

Relationships

None yet

Development

No branches or pull requests

Issue actions