AWS Lambda with API Gateway throwing response error
See original GitHub issueI’m experiencing the same issue outlined in this closed issue. I’m connecting to the lambda via API Gateway and it works fine if I do something like this:
exports.fulfillment = function (event: any, context: any, callback: any) {
app.handler(event, {}).then((res) => {
if (res.status !== 200) {
callback(null, { fulfillmentText: `I got status code: ${res.status}` });
} else {
callback(null, res.body);
}
}).catch((e) => {
callback(null, { fulfillmentText: `There was an error\n${e}` });
});
};
I would love to be able to do it the way your documentation outlines, but if I do I get a TypeError:
{
"errorMessage": "Cannot convert undefined or null to object",
"errorType": "TypeError",
"stackTrace": [
"Function.keys (<anonymous>)",
"Lambda.<anonymous> (/var/task/node_modules/actions-on-google/dist/framework/lambda.js:36:36)",
"Generator.next (<anonymous>)",
"/var/task/node_modules/actions-on-google/dist/framework/lambda.js:22:71",
"new Promise (<anonymous>)",
"__awaiter (/var/task/node_modules/actions-on-google/dist/framework/lambda.js:18:12)",
"/var/task/node_modules/actions-on-google/dist/framework/lambda.js:30:46",
"omni (/var/task/node_modules/actions-on-google/dist/assistant.js:44:53)"
]
}
I guess the ask in this issue is either:
- get this working the way it is outlined in the docs
exports.fulfillment = app;
. - Update the docs to match the need for a lmbda wrapping function like I have above.
If I’m missing something in my Lambda or API Gateway config I’d be fine with changing/updating it. Just let me know!
Thanks, Tommy
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:24 (11 by maintainers)
Top Results From Across the Web
Handle Lambda errors in API Gateway - AWS Documentation
For Lambda custom integrations, you must map errors returned by Lambda in the integration response to standard HTTP error responses for your clients....
Read more >How to handle Lambda errors in API Gateway - Fathom
Navigate to API Gateway. · Click Create API · Select HTTP API · Click Add Integration under the Integrations section · Choose an...
Read more >Error Handling in AWS Lambda and API Gateway - Medium
Lastly, if an error is thrown without one of the mapped status codes then the API Gateway will return a 504 Bad Gateway...
Read more >AWS: Passing errors from Lambda to API Gateway
Throwing an error generates the “errorMessage” object key in the Lambda response, which we then configure API Gateway to look for below.
Read more >Fix the Most Common API Gateway Request Errors - Dashbird
AWS API Gateway is an HTTP gateway, and as such, it uses the well-known HTTP status codes to convey its errors to you....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m seeing the same issue but haven’t had time to look into a fix yet. I’ll have to check the proxy integration setting.
Ultimately, I think we just need better documentation for how to run Actions on Google projects on AWS Lambda correctly.
With the release of
2.6.0
through df48d7e1ac9a3172f2f7c3ec76c5767165c098a2, we added support to detect and parse different request formats from lambda.The response format is still the same as before. For now the way to perform custom response logic is still to manually call
app.handler
with your own code logic. But now the library will be able to handle most request formats on its own.Let us know if there are any issues.