Skip to content

Commit 3c3e393

Browse files
authored
fix(parser): lambda function url cognitoIdentity and principalOrgId nullable (#2430)
* fix(parser): change to nullable values * sometimes it's optional, sometimes nullable * soften the requirement with nullish
1 parent 100e223 commit 3c3e393

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

Diff for: packages/parser/src/schemas/apigwv2.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ const RequestContextV2Authorizer = z.object({
1313
accessKey: z.string().optional(),
1414
accountId: z.string().optional(),
1515
callerId: z.string().optional(),
16-
principalOrgId: z.string().optional(),
16+
principalOrgId: z.string().nullish(),
1717
userArn: z.string().optional(),
1818
userId: z.string().optional(),
19-
cognitoIdentity: z.object({
20-
amr: z.array(z.string()),
21-
identityId: z.string(),
22-
identityPoolId: z.string(),
23-
}),
19+
cognitoIdentity: z
20+
.object({
21+
amr: z.array(z.string()),
22+
identityId: z.string(),
23+
identityPoolId: z.string(),
24+
})
25+
.nullish(),
2426
})
2527
.optional(),
2628
lambda: z.record(z.string(), z.any()).optional(),
@@ -42,7 +44,7 @@ const RequestContextV2 = z.object({
4244
.object({
4345
clientCert: APIGatewayCert.optional(),
4446
})
45-
.optional(),
47+
.nullish(),
4648
domainName: z.string(),
4749
domainPrefix: z.string(),
4850
http: RequestContextV2Http,

Diff for: packages/parser/tests/unit/schema/lambda.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@ describe('Lambda ', () => {
1515
lambdaFunctionUrlEvent
1616
);
1717
});
18+
19+
it('should parse url IAM event', () => {
20+
const urlIAMEvent = TestEvents.lambdaFunctionUrlIAMEvent;
21+
22+
expect(LambdaFunctionUrlSchema.parse(urlIAMEvent)).toEqual(urlIAMEvent);
23+
});
1824
});

0 commit comments

Comments
 (0)