You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My team is trying to use `aws-lambda-powertools' validation utility to validate request/response schemas on a couple of lambda functions we have and we noticed that the envelope parameter is not being taken in consideration when provided.
What were you trying to accomplish?
We have an SQS queue that subscribes to an SNS topic and a lambda function that subscribes to the SQS queue. Which I think is fairly common pattern. I was trying to annotate the request handler with validate to put some validation on the event that originated from the SNS topic schema and as such I needed to use the envelope parameter.
I expected the Validation to use the envelope provided, but I think powertools is actually using the envelope for SQSEvents. I was expecting the default behavior to be overridden by the provided envelope.
Current Behavior
Looking at the code in ValidationAspect.java#L108, I see that the provided envelope will be used as the last resort. And since my event is an SQSEvent, it evaluates to true on ValidationAspect.java#L71 and as such my envelope is not being used.
The current behavior is enforcing a one solution fits all for validating all the builtin events.
Possible Solution
Test if the envelope is not empty at the start of the if...else block and if so use it. This would allow the user to override the default behavior which enables clients to customize the validation as they want.
Steps to Reproduce (for bugs)
Create an SNS topic
Subscribe to the topic using an SQS queue
Create a lambda that subscribes to the SQS queue
Try to validate the schema of message that originated from the SNS topic
Environment
Powertools version used: 1.12.2
Packaging format (Layers, Maven/Gradle): Gradle
AWS Lambda function runtime: JAVA11
The text was updated successfully, but these errors were encountered:
My team is trying to use `aws-lambda-powertools' validation utility to validate request/response schemas on a couple of lambda functions we have and we noticed that the envelope parameter is not being taken in consideration when provided.
What were you trying to accomplish?
We have an SQS queue that subscribes to an SNS topic and a lambda function that subscribes to the SQS queue. Which I think is fairly common pattern. I was trying to annotate the request handler with validate to put some validation on the event that originated from the SNS topic schema and as such I needed to use the envelope parameter.
Expected Behavior
I expected the Validation to use the envelope provided, but I think powertools is actually using the envelope for SQSEvents. I was expecting the default behavior to be overridden by the provided envelope.
Current Behavior
Looking at the code in ValidationAspect.java#L108, I see that the provided envelope will be used as the last resort. And since my event is an SQSEvent, it evaluates to true on ValidationAspect.java#L71 and as such my envelope is not being used.
The current behavior is enforcing a one solution fits all for validating all the builtin events.
Possible Solution
Test if the envelope is not empty at the start of the
if...else
block and if so use it. This would allow the user to override the default behavior which enables clients to customize the validation as they want.Steps to Reproduce (for bugs)
Environment
The text was updated successfully, but these errors were encountered: