-
Notifications
You must be signed in to change notification settings - Fork 561
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
NPE with AWS Lambda and API Gateway #281
Comments
Hi @MounicaRamini, can you confirm the version of Serverless Java Container you are using? Looking at that line of code in the latest release it seems harmless since we check for null on multi-value headers in advance. |
Hi @sapessi , Here is the dependency version
|
Thanks, @MounicaRamini - could you test with the latest release (1.3.2)? Also as an FYI, in the next release (1.4) we'll break spring boot 2 support into a separate package and include support for reactive apps (webflux) - see #239. |
@sapessi |
I just checked the blame for the null-check line of code. This was indeed a bug fixed in release 1.3.1 (reported in #232). How can we make it easier for you to upgrade and approve version 1.3.2 at your company? |
Ah!! Am not sure of that. So, the code am following from your repo is good enough to configure and run Lambda Function? |
Yes, the code you are using is correct. I'd recommend upgrading to the latest release of the framework. However, for the time being you can just ensure that the test event you send through the Lambda console conforms to the latest contract and includes the |
@sapessi Thanks for the information.I'll try to test using latest contract format |
@sapessi |
I've looked at the code of the 1.3 release. Looks like the NPE is happening when we try to get the |
@sapessi
Here is the order of Log Output
Are there any chances like, a NPE is thrown in response because of connection attempt to db is failed ? and it could return nothing and that NPE is not handled ? If not, would it work with versions below 1.3 ? |
it might work with older versions, but I would recommend going to the latest. Can you share the test json you are sending to the function? |
Sure @sapessi ,
|
Out of curiosity, what happens when you send this event (The headers and multiValueHeaders would likely be populated by a client with at least a Content-Type and Accept header): {
"resource": "/path/resource",
"path": "/path/resource",
"httpMethod": "POST",
"headers": {},
"multiValueHeaders": {},
"queryStringParameters": null,
"multiValueQueryStringParameters": null,
"pathParameters": null,
"stageVariables": null,
"requestContext": {
"resourcePath": "/path/resource",
"httpMethod": "POST",
"path": "/path/resource",
"accountId": "accountIdNumber",
"protocol": "HTTP/1.1",
"stage": "test-invoke-stage",
"domainPrefix": "testPrefix",
"identity": {
"cognitoIdentityPoolId": null,
"cognitoIdentityId": null,
"apiKey": "test-invoke-api-key",
"principalOrgId": null,
"cognitoAuthenticationType": null,
"userArn": "actual arn",
"apiKeyId": "test-invoke-api-key-id"
}
},
"body": "{ \"Key1\": \"Value1\", \"Key2\": \"Value2\", \"Key3\": \"Vaue3\" }",
"isBase64Encoded": "false"
} Also, make sure that the |
BTW @MounicaRamini, is the version of the library you are using a private fork of this repo? I can't seem to make sense of the error being at |
@sapessi Yeah, I have given path and httpMethod values respective to application.So, when I send this event, I get the above errors which I have mentioned. I took this format and values from APIGateway Test and then sent these values from AWS Lambda Console Test Event as API Gateway was timing out |
@sapessi the version of the library I have picked from my Company's Maven Artifactory |
I created a test app with SpringBoot and version 1.3 of the library. I get an NPE in the same file but at a different line (the same of issue #232), the NPE is related to the missing
The fact that your exception reports a different line, makes me thing that you are using a forked version of the library. If that's the case, we can't help unless we can test with the same jar you are using. |
Setting |
I would, API Gateway will fail the request at 30 seconds anyway so there's no point in keeping Lambda there spinning. One more challenge with this that we are about to resolve in release 1.4: Lambda has a maximum time of 10 seconds for the |
@sapessi Thanks for the information |
…gets sent an event without the multiValueHeaders property (#281). Also moved the ServletContext to be managed by the ServletRequestReader istead of set on each request by the LambdaContainerHandler. Additional bug fix to set the correct dispatcher type when startAsync is called on the request
Scenario
NPE when invoking Lambda Function in AWS Lambda Console
Expected behavior
Should be inserting and fetching records from database when Lambda is invoked
Actual Behaviour
Throws below error, when Lambda is executed by using AWS Lambda Test Events
Error Message on AWS Lambda Console
Full log output on Cloud Wach
LambdaHandler Code
Application.class
The text was updated successfully, but these errors were encountered: