Skip to content

Commit

Permalink
fix(parser): make identitySource optional for ApiGatewayAuthorizerReq…
Browse files Browse the repository at this point in the history
…uestV2 model (#5880)

fix(parser): identitySource is optional for ApiGatewayAuthorizerRequestV2

Co-authored-by: Leandro Damascena <lcdama@amazon.pt>
  • Loading branch information
anafalcao and leandrodamascena authored Jan 17, 2025
1 parent 4a11418 commit cba8861
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aws_lambda_powertools/utilities/parser/models/apigwv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ class APIGatewayProxyEventV2Model(BaseModel):
class ApiGatewayAuthorizerRequestV2(APIGatewayProxyEventV2Model):
type: Literal["REQUEST"]
routeArn: str
identitySource: List[str]
identitySource: Optional[List[str]] = None
9 changes: 9 additions & 0 deletions tests/unit/parser/_pydantic/test_apigwv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

0 comments on commit cba8861

Please sign in to comment.