generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedparserThis item relates to the Parser UtilityThis item relates to the Parser Utility
Description
Expected Behavior
When an SQS queue's event source mapping is configured with a maxBatchingWindow, the md5OfMessageAttributes of the individual Records will be null. The SqsRecordSchema should parse such records.
Current Behavior
The SqsRecordSchema fails to parse records with null md5OfMessageAttributes, returning the error
Expected string, received null at "Records[0].md5OfMessageAttributes"
Code snippet
Create a Lambda handler using the S3SqsEventSchema defined below:
const S3TestEventSchema = z.object({
Event: z.literal('s3:TestEvent'),
Bucket: z.string(),
});
const S3EventRecordsSchema = S3Schema.transform((val) => val.Records[0]);
const S3EventSchema = z.union([S3EventRecordsSchema, S3TestEventSchema]);
const S3SqsEventRecordSchema = SqsRecordSchema.extend({
body: JSONStringified(S3EventSchema),
});
export const S3SqsEventSchema = z.object({
Records: z.array(S3SqsEventRecordSchema).nonempty(),
});
In our case, we are processing S3 events sent to an SQS queue. But the issue should be reproducible for any event type.
Steps to Reproduce
Create a Lambda function to process an SQS queue whose event source mapping includes a maxBatchingWindow.
Possible Solution
Allow md5OfMessageAttributes to be nullable:
md5OfMessageAttributes: z.string().optional().nullable(),
Powertools for AWS Lambda (TypeScript) version
latest
AWS Lambda function runtime
20.x
Packaging format used
npm
Execution logs
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcompletedThis item is complete and has been merged/shippedThis item is complete and has been merged/shippedparserThis item relates to the Parser UtilityThis item relates to the Parser Utility
Type
Projects
Status
Shipped