-
Notifications
You must be signed in to change notification settings - Fork 475
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
Deserialization error in Cognito triggered lambda for CUSTOM_AUTH flow #1644
Comments
Most likely the model from Cognito events changed and the corresponding POCO class needs an update. |
@ankushjain358 Good afternoon. Here are my observations:
Please confirm the following:
Thanks, |
Is your use case is that the default event object set by Cognito has null for these values having issue and that the Lambda Cognito Event POCO classes should allow null values for these fields? Is it possible to share end-to-end setup (without manually using customized response JSON) with steps, so that we could reproduce the issue at our end?
Is it possible to contribute a PR for the fix (the fix appears to be pretty trivial) along with unit test cases? |
@ashishdhingra - Any update here? |
@ankushjain358 Could you please share sample JSON for testing in text format (not the image)? We would prefer actual JSON that you encounter as logged in CloudWatch. |
@ashishdhingra I have provided entire sample in zip file with the steps to reproduce in one of above comments. Can you please just deploy the zipped solution using SAM and reproduce the issue. That way you will also get the event JSON from CloudWatch. |
@ankushjain358 I reviewed this with the team. Since you have reproduced it end-to-end, we would instead write the unit test case against the JSON you share and make changes to POCO classes. Feel free to contribute PR so that this could be merged to library soon. This would be a breaking change since we are changing data types and would require major version bump, including call out in changelog. |
@ashishdhingra - I've created a pull request to address the issue. Also, I don't believe this would require changes to test cases because I've seen a few other events with nullable bool properties, such as PR Link - #1646 |
Thanks again for the PR! This has been released in Amazon.Lambda.CognitoEvents v3.0.0. |
|
Describe the bug
To enable CUSTOM_AUTH flow, I created below 3 Lambda functions in .NET, and used
Amazon.Lambda.CognitoEvents
NuGet package v2.2.0 for input events.Out of above 3, two Lambda functions are failing while deserializing incoming event JSON to .NET type. It seems that Cognito is sending boolean values as null, while respective .NET properties are not nullable.
Here are the .NET Types which are creating issue:
response.issueTokens
should be nullableresponse.failAuthentication
should be nullableresponse.answerCorrect
should be nullableExpected Behavior
The .NET Lambda function should be triggered with the incoming event JSON without any error.
Current Behavior
The .NET Lambda function fails for the following triggers when using types defined in
Amazon.Lambda.CognitoEvents
library.Reproduction Steps
Create lambda function as per below syntax for Cognito triggers.
DefineAuthChallenge
VerifyAuthChallenge
Use the following JSON as input event, just make the boolean fields
null
.Possible Solution
Update boolean properties to nullable boolean.
response.issueTokens
should be nullableresponse.failAuthentication
should be nullableresponse.answerCorrect
should be nullableAdditional Information/Context
AWS .NET SDK and/or Package version used
Targeted .NET Platform
.NET 6
Operating System and version
Windows 10, Amazon Linux 2
The text was updated successfully, but these errors were encountered: