502 Error on Lambda
See original GitHub issueHi,
i have a Problem, when i deploy the project to my aws account.
Local -> Everything works fine. AWS -> i get back 502 Internal Server Error.
When i test the AWS Lambda in the online console i get:
Execution log for request test-request Sun May 07 00:24:12 UTC 2017 : Starting execution for request: test-invoke-request Sun May 07 00:24:12 UTC 2017 : HTTP Method: POST, Resource Path: /graphql Sun May 07 00:24:12 UTC 2017 : Method request path: {} Sun May 07 00:24:12 UTC 2017 : Method request query string: {} Sun May 07 00:24:12 UTC 2017 : Method request headers: {} Sun May 07 00:24:12 UTC 2017 : Method request body before transformations: {viewer{id}} Sun May 07 00:24:12 UTC 2017 : Endpoint request URI: https://lambda.eu-central-1.amazonaws.com/2015-03-31/functions/arn:aws:lambda:eu-central-1:000000000:function:serverless-myapp-production-api/invocations Sun May 07 00:24:12 UTC 2017 : Endpoint request headers: {x-amzn-lambda-integration-tag=test-request, Authorization=*******************************************************************************************************************************************************************************************************************************************************************************************************************************************39966f, X-Amz-Date=20170507T002412Z, x-amzn-apigateway-api-id=000000000, X-Amz-Source-Arn=arn:aws:execute-api:eu-central-1:000000000:wmxk0au92f/null/POST/graphql, Accept=application/json, User-Agent=AmazonAPIGateway_wmxk0au92f, X-Amz-Security-Token=000000000 [TRUNCATED] Sun May 07 00:24:12 UTC 2017 : Endpoint request body after transformations: {"resource":"/graphql","path":"/graphql","httpMethod":"POST","headers":null,"queryStringParameters":null,"pathParameters":null,"stageVariables":null,"requestContext":{"accountId":"000000000","resourceId":"000000000","stage":"test-invoke-stage","requestId":"test-invoke-request","identity":{"cognitoIdentityPoolId":null,"accountId":"000000000","cognitoIdentityId":null,"caller":"000000000","apiKey":"test-invoke-api-key","sourceIp":"test-invoke-source-ip","accessKey":"abcd","cognitoAuthenticationType":null,"cognitoAuthenticationProvider":null,"userArn":"arn:aws:iam::00000:user/abcd","userAgent":"Apache-HttpClient/4.5.x (Java/1.8.0_112)","user":"000000000"},"resourcePath":"/graphql","httpMethod":"POST","apiId":"000000000"},"body":"{viewer{id}}","isBase64Encoded":false} Sun May 07 00:24:13 UTC 2017 : Endpoint response body before transformations: {"errorMessage":"RequestId: 000000000 Process exited before completing request"} Sun May 07 00:24:13 UTC 2017 : Endpoint response headers: {x-amzn-Remapped-Content-Length=0, x-amzn-RequestId=000000000, Connection=keep-alive, Content-Length=107, X-Amz-Function-Error=Unhandled, Date=Sun, 07 May 2017 00:24:12 GMT, X-Amzn-Trace-Id=root=000000000;sampled=0, Content-Type=application/json} Sun May 07 00:24:13 UTC 2017 : Execution failed due to configuration error: Malformed Lambda proxy response Sun May 07 00:24:13 UTC 2017 : Method completed with status: 502
Any ideas? My api folder is pretty the same, as in the example - i only changed the s3 bucket and the region in my serverless.yaml
Greetings Tobias
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (1 by maintainers)
+1 Managed to solve this using
This leads me to believe that it is to do with the lambda proxy expecting a different response. And therefore getting a malformed lambda proxy response error.
If a method is Lambda proxy integration then the response body is expected to be JSON object. I had the same issue as I was using JSON.stringify(result) where result was a JSON object. I don’t explicitly specify the integration on the serverless.yml however test run on aws shows 💯 Endpoint request headers: {x-amzn-lambda-integration-tag=test-request
After changing request to result my method started working for the endpoints: