-
Notifications
You must be signed in to change notification settings - Fork 560
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
Change method naming of AwsProxyRequest for Jackson and other serializers. #262
Comments
This should be treated as a high priority as it is causing requests to |
Thanks for the feedback @Marclev78 - I'll work to replicate and push a fix with the next patch release. Hoping to get it out this week. |
Hey @Marclev78, I have a fix for this about to go out in the core branch. However, I doubt this is the cause of your issue. Requests are only de-serialized, which happens correctly, the framework never serializes them. Still, I have added the annotation on the field like we do in the response to make sure this happens correctly. Can you share a stack trace of what is happening with SAM local so that we can figure out what the root cause of the issue is? |
Release 1.3.2 - which includes this fix - is on its way to maven central! Resolving this issue. |
I am experiencing this issue using the latest 1.3.2 version. |
Hi @gakinson, the annotation is definitely there in the latest release (code). I suspect your issue may be caused by the fact that you are using the typed handler rather than the stream one: The typed handler (receives a proxy event + context and returns a proxy response) uses Lambda's built-in serialization mechanism which does not read/use annotations. I would recommend switching to the stream handler (see the examples). The stream handler uses the object mapper included in this framework which will respect the annotations. |
Hello @sapessi , Thanks for the prompt response. I can switch to use that to test, but I also just created a new instance of a jackson ObjectMapper which should respect annotations, I think, but it still does not do the deserialization correctly. Thank you, |
Here is my post from thread aws/aws-sam-cli#1193 : Hello, here are my notes on how I could get it working by duplicating your class and playing around with annotations. Failed attempts
Successful attempts
Still trying some others that are backwards compatible, but please address this in some way. |
I have tried this using RequestStreamHandler and it all works. I read a little more regarding RequestHandler and I see now. Thanks for your patience. |
Great! Apologies for missing your earlier messages @gakinson |
When you use a typed handler ( |
What's odd is, when running This is using 1.3.2 and the typed handler. |
Which Lambda runtime are you using @kastork? |
@sapessi I'm using java11 |
@sapessi Because of your question, I tried it with |
@sapessi This really is a problem with class Also, as can be seen in the linked issue for SAM CLI, this tool is totally unforgiving in handling responses with the wrong property Would you be willing to provide both properties |
Serializer like Jackson's ObjectMapper are using method names for serialization and deserialization.
Prefixes like get/set/is will be removed and the following String will be used as parameter names.
For the property isBase64Encoded the method names are:
See: https://github.com/awslabs/aws-serverless-java-container/blob/e4f4d4de6016a60d3fe728181d24aa4d91e645ec/aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/model/AwsProxyRequest.java#L171
This leads to a serialization of
{ "base64Encoded" }
which can not be deserialized because the expected value name is: isBase64Encoded
Please rename the getter to getIsBase64Encoded or isIsBase64Encoded, so that the property is serialized as:
{ "isBase64Encoded" }
The text was updated successfully, but these errors were encountered: