diff --git a/aws_lambda_powertools/utilities/parser/models/apigwv2.py b/aws_lambda_powertools/utilities/parser/models/apigwv2.py index 943d42a8e01..540e7c1a30b 100644 --- a/aws_lambda_powertools/utilities/parser/models/apigwv2.py +++ b/aws_lambda_powertools/utilities/parser/models/apigwv2.py @@ -72,4 +72,4 @@ class APIGatewayProxyEventV2Model(BaseModel): class ApiGatewayAuthorizerRequestV2(APIGatewayProxyEventV2Model): type: Literal["REQUEST"] routeArn: str - identitySource: List[str] + identitySource: Optional[List[str]] = None diff --git a/tests/unit/parser/_pydantic/test_apigwv2.py b/tests/unit/parser/_pydantic/test_apigwv2.py index cec9e05bccd..ddb849bb68a 100644 --- a/tests/unit/parser/_pydantic/test_apigwv2.py +++ b/tests/unit/parser/_pydantic/test_apigwv2.py @@ -130,3 +130,12 @@ def test_apigw_v2_request_authorizer(): assert parsed_event.type == raw_event["type"] assert parsed_event.identitySource == raw_event["identitySource"] assert parsed_event.routeArn == raw_event["routeArn"] + + +def test_apigw_v2_request_authorizer_without_identity_source(): + raw_event = load_event("apiGatewayAuthorizerV2Event.json") + raw_event["identitySource"] = None + + parsed_event: ApiGatewayAuthorizerRequestV2 = ApiGatewayAuthorizerRequestV2(**raw_event) + + assert parsed_event.identitySource == raw_event["identitySource"]