aws / serverless-java-container

A Java wrapper to run Spring, Spring Boot, Jersey, and other apps inside AWS Lambda.
https://aws.amazon.com/serverless/
Apache License 2.0
1.47k stars 551 forks source link

AwsProxyResponse class is generating response JSON which is rejected by API gateway with Malformed error #884

Open Chiranjibeem opened 2 months ago

Chiranjibeem commented 2 months ago

We are calling java lambda from api gateway and in cloudwatch logs i can see internal server error is coming,

After going through the logs and support team i got to know that AwsProxyResponse class is generating response JSON which is rejected by API gateway with Malformed error

Json generated is using field name base64Encoded instead of isBase64Encoded

deki commented 2 months ago

Hi @Chiranjibeem, can you please fill out the issue template to help us looking into your issue? The property is named explicitly https://github.com/aws/serverless-java-container/blob/main/aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/model/AwsProxyResponse.java#L122 so I wonder what makes the serialization ignore it in your case.

To help us debug your issue fill in the basic information below using the options provided

Serverless Java Container version: eg. 1.5

Implementations: Jersey / Spring / Spring Boot / Spring Boot 2 / Spark

Framework version: eg SpringBoot 2.2.6.RELEASE

Frontend service: REST API / HTTP API / ALB

Deployment method: eg SAM, Serverless Framework, Console

Scenario

Describe what you are trying to accomplish

Expected behavior

Describe how you would expect the application to behave

Actual behavior

Describe what you are seeing instead

Steps to reproduce

Provide code samples we can use to reproduce the issue as part of our integration tests. If there is a public repository for the misbehaving application link to it here

Full log output

Paste the full log output from the Lambda function's CloudWatch logs

logs
Chiranjibeem commented 2 months ago

Serverless Java Container version: 2.0.0-M2

Implementations: Spring Boot

Framework version: SpringBoot 3.2.0

Frontend service: AWS API Gateway

Deployment method: Serverless Framework

Scenario - When we are trying to invoke lambda with proxy integration from apigateway, apigateway is throwing malformed error

Expected Behaviour - as part of lambda response, api gatway is expecting isBase64Encoded value but from lambda response we are getting only base64Encoded key

Actual Behaviour - isBase64Encoded should come ans statusDescriptions also not required as per api gateway

Stepa to reproduce - Create a api gatway Call lambda ( rerurn type should be AwsProxyResponse) Invoke Lambda from ApIGAteway

deki commented 1 month ago

Can you please try reproducing it using our sample https://github.com/aws/serverless-java-container/tree/main/samples/springboot3/pet-store?

We have multiple unittests in place that cover it so I can only imagine it's related to specific configurations inside your application.