Open StefanVanDyck opened 3 years ago
/cc @matejvasek, @patriot1burke
Forgot to mention the work around was to add a custom Date Deserializer to quarkus.
This was easily achieved using an ObjectMapperCustomizer
and copying the logic from com.amazonaws.services.lambda.runtime.serialization.events.modules.DateModule
.
It just seems like this should work out-of-the-box when using the aws lambda extension.
You are not using the quarkus dynamo extension correct? I agree this should work out of the box. We're having a bit of problem with deserializing AWS event types. They all seem to follow a different pattern. Some of the classes don't have setter methods, and it looks like others like dynamo do different date serialization.
lambda-deserializer-reproducer.tar.gz
Indeed, I am not using the dynamo extension. I included a small reproducer starting from the lambda maven archetype with no additions.
It has 2 "integration" tests that mimick the behaviour on AWS.
Issue still exists on Quarkus 1.12.0
Issue still exists in Quarkus 2.1.1
new version, V4, of Events library is coming https://github.com/aws/aws-lambda-java-libs/issues/282
Issue still exists in Quarkus 3.6.7
@patriot1burke ^
Describe the bug When running my DynamoDB-stream triggered lambda I receive the following error:
2021-01-21 01:37:10,665 ERROR [io.qua.ama.lam.run.AbstractLambdaPollLoop] (Lambda Thread) Failed to run lambda: com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of
java.util.Dateout of VALUE_NUMBER_FLOAT token at [Source: (sun.net.www.protocol.http.HttpURLConnection$HttpInputStream); line: 1, column: 196] (through reference chain: com.amazonaws.services.lambda.runtime.events.DynamodbEvent["Records"]->java.util.ArrayList[0]->com.amazonaws.services.lambda.runtime.events.DynamodbEvent$DynamodbStreamRecord["dynamodb"]->com.amazonaws.services.lambda.runtime.events.models.dynamodb.StreamRecord["ApproximateCreationDateTime"]) ... at io.quarkus.amazon.lambda.runtime.AbstractLambdaPollLoop$1.run(AbstractLambdaPollLoop.java:78)
This happens because AWS passes unix timestamps as a float value with milliseconds after the decimal point.
My handleRequest method looks like this:
public LambdaResponse handleRequest(com.amazonaws.services.lambda.runtime.events.DynamodbEvent trigger, Context context)
I am using a native build(GraalVM), not sure if that matters.
Expected behavior I expect the lambda to be trigger using a Strongly-Type Java Object as event.
Actual behavior The lambda Crashes with a jackson Deserialization error.
To Reproduce
Will provide reproducer.
Steps to reproduce the behavior:
Configuration
Environment (please complete the following information):