Skip to content

Feature request: APIGatewayRestResolver exception_handler compress data #2513

Closed
@royassis

Description

@royassis

Expected Behaviour

exception_handler does not compress response

Current Behaviour

exception_handler compress response if decorator contained compress=True

Code snippet

from aws_lambda_powertools.event_handler import content_types

@app.exception_handler(Exception)
def handle_invalid_params(ex: Exception):
    response = Response(
            status_code=500,
            content_type=content_types.APPLICATION_JSON,
            body=json.dumps({"ex": str(ex)})
        )
    return response 

@app.get("/", compress=True)
def foo(datasetid: str):
    raise Exception

Possible Solution

No response

Steps to Reproduce

Run code snippet

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.7

Packaging format used

Serverless Application Repository (SAR) App

Debugging logs

No response

Metadata

Metadata

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions