You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
invocation_response::failure does not work with HTTP API Gateway ? #117
I'm using the HTTP API Gateway, my c++ runtime is built with amazonlinux:latest in a docker image.
All responses that return with invocation_response::failure return an Error 500, Internal Server Error.
#include <aws/lambda-runtime/runtime.h>
using namespace aws::lambda_runtime;
static invocation_response my_handler(invocation_request const& req)
{
return invocation_response::failure("error message here"/*error_message*/, "error type here" /*error_type*/);
}
int main()
{
run_handler(my_handler);
return 0;
}
However, when I use invocation_response::success, the message arrives on my requesting client, but I ofc. can only send json objects back. (Anyone got an idea why that is ?)
I read everything google found and digged through all kinds of files and aws docus, I could not find out where the problem is. Could someone please give me a hint if the args have to match some specific ones or what I am doing wrong ?
Thanks!
The API Gateway example produced an internal server error even when I posted successful responses. I think it is because I created a REST API gateway.
What I found is that the API Gateway expects a specific response structure. When I used this structure my successful responses worked.
So it seems that when you use invocation_response::failure you report to the API Gateway that you cannot reply to this request. It then emits a 500
If you want to send a 400 error to the caller, you should include statusCode: 400 as part of the response structure and use invocation_response::success to send the structure through.
So maybe the solution is to switch to a REST API instead of an HTTP API?
Activity
darrenwinslow commentedon Sep 24, 2021
I am having the same issue. Did you ever figure this out?
wduminy commentedon Jul 18, 2022
The API Gateway example produced an internal server error even when I posted successful responses. I think it is because I created a REST API gateway.
What I found is that the API Gateway expects a specific response structure. When I used this structure my successful responses worked.
So it seems that when you use
invocation_response::failureyou report to the API Gateway that you cannot reply to this request. It then emits a500If you want to send a
400error to the caller, you should includestatusCode: 400as part of the response structure and useinvocation_response::successto send the structure through.So maybe the solution is to switch to a REST API instead of an HTTP API?
From the docs