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

Invalid API Gateway Response Keys: set([u'multiValueHeaders']) in with sam local start-api #1190

Closed
AyushG3112 opened this issue May 20, 2019 · 13 comments

Comments

@AyushG3112
Copy link

AyushG3112 commented May 20, 2019

Description

I am trying to test my local function with sam local start-api but it appears to make an useless validation to the response.

Observed result

Invalid API Gateway Response Keys: set([u'multiValueHeaders']) in {u'body': u'{"Status":true,"Message":"OTP Generated"}', u'headers': {u'Content-Type': u'application/json'}, u'multiValueHeaders': {}, u'statusCode': 200}

Function returned an invalid response (must include one of: body, headers or statusCode in the response object). Response received: {"statusCode":200,"headers":{"Content-Type":"application/json"},"multiValueHeaders":{},"body":"{\"Status\":true,\"Message\":\"OTP Generated\"}"}

Expected result

Describe what you expected.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Ubuntu 16.04
  2. sam --version: SAM CLI, version 0.16.0
@AyushG3112 AyushG3112 changed the title Invalid API Gateway Response Keys: set([u'multiValueHeaders']) in Invalid API Gateway Response Keys: set([u'multiValueHeaders']) in with sam local start-api May 20, 2019
@jfuss
Copy link
Contributor

jfuss commented May 20, 2019

Duplicate of #830

Closing

@jfuss jfuss closed this as completed May 20, 2019
@btipling
Copy link

@jfuss I think this may be a different issue from #830 because in this case it returns an error from the local API Gateway level. #830 didn't return an error I think.

@jfuss
Copy link
Contributor

jfuss commented May 20, 2019

At the root of it, we need to support multiValueHeaders. So the ask here is the same as the other issue.

@btipling
Copy link

btipling commented May 21, 2019

The issue though seems to be that something is preventing from even a basic hello world from succeeding in my codebase. All my lambdas are currently failing with 502 HTTP errors, something changed that introduced the multiValueHeaders or the new 502 errors without any code changes. I haven't created a reduced reproducible example yet, because I am not entirely sure that it isn't something wrong with my vendor or some version conflict. I did a quick search for this error and saw this and thought maybe someone else was running into this as well.

@btipling
Copy link

btipling commented May 21, 2019

Reverting to 0.15.0 resolved my issue. It looks like there is a conflict with some of the golang aws packages that send the multivalue headers. They were ignored, but now they generate a 502 error breaking all endpoints for something being generated by an aws lib.

$ cd vendor/github.com/; ag -li multivalue
awslabs/aws-lambda-go-api-proxy/core/request.go
awslabs/aws-lambda-go-api-proxy/core/response.go
aws/aws-lambda-go/events/alb.go
aws/aws-lambda-go/events/apigw.go

When I manually removed the references in structs to multivalue in these files:

vendor/github.com/awslabs/aws-lambda-go-api-proxy/core/response.go
vendor/github.com/aws/aws-lambda-go/events/alb.go
vendor/github.com/aws/aws-lambda-go/events/apigw.go

The 502s stopped with this change, but instead of settling with this as a temporary fix, I just reverted to 0.15.0 and the problem went away. I think this is a separate issue worth investigating. The 502 is harsh given that other aws official libs are automatically sending that header. It wasn't fun to suddenly have everything break on me without any changes on my part. Having said that, I appreciate the value this tool brings and am grateful for all the work that has gone into it. Just providing some feedback about user experience.

@jfuss
Copy link
Contributor

jfuss commented May 21, 2019

@btipling So there are multiple things at play here. We made some of our validation on returns (in the Api Gateway context) to match what the service does. When doing this, we did not add support for multiValueHeaders since start-api doesn't actually support this yet. So while we are now failing because of these 'unexpected' values it is actually an expected behavior until we support multiValueHeaders. This is why the two issues are the same even though the error is different (the other issue was just created before it started erroring out like this).

@AyushG3112
Copy link
Author

@jfuss can we patch a fix in for now till the proper fix is merged and released?

@jfuss
Copy link
Contributor

jfuss commented May 21, 2019

We have an open PR that is currently being iterated on. Downgrading the CLI will be the path forward until we merge the PR and release.

@havsar
Copy link

havsar commented May 31, 2019

Reverting to 0.15.0 worked for me too.

0.15.0 release link: https://github.com/awslabs/aws-sam-cli/releases/tag/v0.15.0

@thomasdane
Copy link

Can anyone provide instructions to downgrade? I cannot do it with brew. I am getting the same error as above:

Invalid API Gateway Response Keys: {'errorMessage', 'errorType'} in {'errorType': 'exitError', 'errorMessage': 'RequestId: 1e4f60ae-536a-1238-8ddd-5c4ee5cbf249 Error: fork/exec /var/task/main: no such file or directory'}
Function returned an invalid response (must include one of: body, headers, multiValueHeaders or statusCode in the response object). Response received: {"errorType":"exitError","errorMessage":"RequestId: 1e4f60ae-536a-1238-8ddd-5c4ee5cbf249 Error: fork/exec /var/task/main: no such file or directory"}

@jfuss
Copy link
Contributor

jfuss commented Dec 7, 2019

@thomasdane if you look at your output closely, you will see that /var/task/main does not exist. This is most likely due to docker shared setting not being configured to allow the directory. If your on windows and already have the drive shared correctly, toggling the setting is the best way to get docker to remember it can share. Your error does not relate to this issue.

@ranjitparva
Copy link

For Kotlin:
@get:JvmName("getIsBase64Encoded") val base64Encoded: Boolean = false

@ramblingbarney
Copy link

ramblingbarney commented Dec 9, 2020

on aws-cli/1.17.13 Python/2.7.17 Linux/4.19.0-10-amd64 botocore/1.14.13

Mounting /home/conor/workspace/sam-app/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container
START RequestId: 471f2d40-3881-4ce7-946d-731b16c60992 Version: $LATEST
fork/exec /var/task/hello-world: no such file or directory: PathError
null
END RequestId: 471f2d40-3881-4ce7-946d-731b16c60992
REPORT RequestId: 471f2d40-3881-4ce7-946d-731b16c60992	Init Duration: 0.39 ms	Duration: 46.55 ms	Billed Duration: 100 ms	Memory Size: 128 MB	Max Memory Used: 128 MB	
Lambda returned empty body!
Invalid lambda response received: Invalid API Gateway Response Keys: {'errorMessage', 'errorType'} in {'errorMessage': 'fork/exec /var/task/hello-world: no such file or directory', 'errorType': 'PathError'}
2020-12-09 21:14:13 127.0.0.1 - - [09/Dec/2020 21:14:13] "GET /hello HTTP/1.1" 502 -

I have this error when running locally, deploying using the guided switch also fails with internal server error when invoked

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

No branches or pull requests

7 participants