Skip to content

Bug: Exception handling doesn't work with data validation #3395

Closed
@rubenfonseca

Description

@rubenfonseca

Expected Behaviour

The exception handling functionality should work when data validation is enabled, including when the validation fails.

Current Behaviour

The exception handler is not called

Code snippet

app = APIGatewayRestResolver(enable_validation=True)

@app.exception_handler(RequestValidationError)
def handle_invalid_data(ex: RequestValidationError):
    return Response(
        status_code=422,
        content_type=content_types.TEXT_PLAIN,
        body="Invalid request parameters.",
    )

Possible Solution

No response

Steps to Reproduce

  1. Use the code snippet above
  2. Send a request that fails validation
  3. The exception handler is not called

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

Type

No type

Projects

Status

Shipped

Relationships

None yet

Development

No branches or pull requests

Issue actions