Skip to content

Bug: APIGateWayProxyEvent.request_context.authorizer results in KeyError #4102

Closed
@dirkdebruin

Description

@dirkdebruin

Expected Behaviour

returns authorizer dictionary

Current Behaviour

KeyError

Code snippet

powertools-lambda-python/aws_lambda_powertools/utilities/data_classes/api_gateway_proxy_event.py
line 94 in class APIGatewayEventRequestContext

 def authorizer(self) -> APIGatewayEventAuthorizer:
        return APIGatewayEventAuthorizer(self._data["requestContext"]["authorizer"])

Possible Solution

 def authorizer(self) -> APIGatewayEventAuthorizer:
        return APIGatewayEventAuthorizer(self.["requestContext"].get("authorizer"))

Steps to Reproduce

@event_source(data_class=APIGatewayProxyEvent)
def handler(event: APIGatewayProxyEvent, context):
    authorizer = event.request_context.authorizer

Powertools for AWS Lambda (Python) version

2.36.0

AWS Lambda function runtime

3.11

Packaging format used

PyPi

Debugging logs

No response

Metadata

Metadata

Labels

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions