Skip to content

Bug: APIGatewayProxyEventV2.decoded_body should not cause KeyError #3706

Closed
@aahung

Description

@aahung

Expected Behaviour

For event of type APIGatewayProxyEventV2, event.decoded_body or event.json_body (which calls the former) could result in KeyError when there is no body.

Current Behaviour

image

Code snippet

`event.decoded_body` or `event.json_body`

Possible Solution

  • event.decoded_body should return empty string or None
  • event.json_body should raise JSONDecodeError

Steps to Reproduce

As described.

Powertools for AWS Lambda (Python) version

latest

AWS Lambda function runtime

3.11

Packaging format used

PyPi

Debugging logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Shipped

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions