Skip to content

Commit 181fc33

Browse files
fix(parser): API Gateway V2 request context scope field should be optional (#2961)
1 parent bfde1c9 commit 181fc33

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

aws_lambda_powertools/utilities/parser/models/apigwv2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RequestContextV2AuthorizerIam(BaseModel):
2525

2626
class RequestContextV2AuthorizerJwt(BaseModel):
2727
claims: Dict[str, Any]
28-
scopes: List[str]
28+
scopes: Optional[List[str]] = None
2929

3030

3131
class RequestContextV2Authorizer(BaseModel):

tests/unit/parser/test_apigwv2.py

+7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ def test_apigw_v2_event_jwt_authorizer():
6363
assert parsed_event.stageVariables == raw_event["stageVariables"]
6464

6565

66+
def test_apigw_v2_event_empty_jwt_scopes():
67+
raw_event = load_event("apiGatewayProxyV2Event.json")
68+
raw_event["requestContext"]["authorizer"]["jwt"]["scopes"] = None
69+
70+
APIGatewayProxyEventV2Model(**raw_event)
71+
72+
6673
def test_api_gateway_proxy_v2_event_lambda_authorizer():
6774
raw_event = load_event("apiGatewayProxyV2LambdaAuthorizerEvent.json")
6875
parsed_event: APIGatewayProxyEventV2Model = APIGatewayProxyEventV2Model(**raw_event)

0 commit comments

Comments
 (0)