Skip to content
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

invocation_response::failure does not work with HTTP API Gateway ? #117

Open
fxfire opened this issue Feb 27, 2021 · 2 comments
Open

invocation_response::failure does not work with HTTP API Gateway ? #117

fxfire opened this issue Feb 27, 2021 · 2 comments

Comments

@fxfire
Copy link

fxfire commented Feb 27, 2021

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!

@darrenwinslow
Copy link

I am having the same issue. Did you ever figure this out?

@wduminy
Copy link

wduminy commented 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::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?

From the docs

Choose REST APIs if you need features such as API keys, per-client throttling, request validation, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants