-
Notifications
You must be signed in to change notification settings - Fork 171
feat(parser): integrate parser with Batch Processing #4408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Can you also please address all the Sonar findings? |
@dreamorosi I'm still a bit confused about extending the if (eventType === EventType.KinesisDataStreams) {
const extendedSchemaParsing = parse(record, undefined, schema, true);
if (extendedSchemaParsing.success)
return extendedSchemaParsing.data as KinesisStreamRecord;
if (schema['~standard'].vendor === SchemaType.Zod) {
const { JSONStringified } = await import(
'@aws-lambda-powertools/parser/helpers'
);
const { KinesisDataStreamRecord } = await import(
'@aws-lambda-powertools/parser/schemas/kinesis'
);
const extendedSchema = KinesisDataStreamRecord.extend({
// biome-ignore lint/suspicious/noExplicitAny: The vendor field in the schema is verified that the schema is a Zod schema
data: // Decompress and decode the data to match against schema
});
return parse(record, undefined, extendedSchema);
}
console.warn(
'The schema provided is not supported. Only Zod schemas are supported for extension.'
);
throw new Error('Unsupported schema type');
} To extend it, should I create another helper which does the decompressions and decoding? |
I've been thinking about your question for a while and there's no straightforward way to do it with our current feature set. We can't use envelopes because of what you mentioned, and doing the parsing in two parts while possible, is suboptimal for two reasons:
With this in mind, I think we'll have to extract the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a couple of last styling and documentation details and then we're good to merge!
…:aws-powertools/powertools-lambda-typescript into feat/parser-integration-batch-processing
|
Summary
This PR integrates the Parser functionality with the Batch Processor so that customers can parse and validate payloads before they're passed to the record handler. It supports both the extended schemas for the SQSRecord, KinesisRecord, and DynamoDBRecord as well as the inner payload schema.
Changes
BasePartialBatchProcessor
to set the schema propertyparseRecord
method to theBatchProcessor
to do the parsing by dynamically importing the parse function and the appropriate schemaIssue number: closes #4394
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.