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
I tried to make a chalice app and deploy it locally with sam local, which worked but every API call i make return "method unsupported: " as if sam-local wasn't giving the lambda the http method.
I'm kinda new to public PRs, I cloned, created a branch and commited but don't have permission to push. I sadly don't have any time right now to look into this.
I also didn't see tests for event.go, so I assumed this would be the only change needed.
I can see #143 was merged, but came across a similar issue today. Did this ever get resolved successfully?
chalice 1.1.0 and aws-sam-local build from develop today.
chalice new-project hello-world && cd hello-world
chalice package package && cd package
sam local start-api -t sam.json
curl -v http://localhost:3000/
2018/02/09 10:14:20 Invoking app.app (python3.6)
2018/02/09 10:14:20 Decompressing /home/kadrach/source/hello/out/deployment.zip
START RequestId: 66a9cddc-6053-4436-bce0-36c64e5c9a33 Version: $LATEST
'queryStringParameters': KeyError
Traceback (most recent call last):
File "/var/task/chalice/app.py", line 598, in __call__
self.current_request = Request(event['queryStringParameters'],
KeyError: 'queryStringParameters'
END RequestId: 66a9cddc-6053-4436-bce0-36c64e5c9a33
REPORT RequestId: 66a9cddc-6053-4436-bce0-36c64e5c9a33 Duration: 10 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 20 MB
2018/02/09 10:14:21 Function returned an invalid response (must include one of: body, headers or statusCode in the response object): %!s(<nil>)
Unchanged if using --prefix-routing option introduced in #143.
Activity
ehault commentedon Sep 26, 2017
after going into the chalice code, it appear that it's expecting the event inside the requestContext field
http_method = event['requestContext']['httpMethod']
and the event received:
{'httpMethod': 'GET', 'body': '', 'resource': '/', 'requestContext': {'resourceId': '', 'apiId': '', 'resourcePath': '/', 'httpMethod': '', 'requestId': '', 'accountId': '', 'identity': {'apiKey': '', 'userArn': '', 'cognitoAuthenticationType': '', 'caller': '', 'userAgent': '', 'user': '', 'cognitoIdentityPoolId': '', 'cognitoIdentityId': '', 'cognitoAuthenticationProvider': '', 'sourceIp': '127.0.0.1:63897', 'accountId': ''}}, 'queryStringParameters': {}, 'headers': {'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8', 'Accept-Encoding': 'gzip, deflate, br', 'Accept-Language': 'en-US,en;q=0.8', 'Cache-Control': 'max-age=0', 'Connection': 'keep-alive', 'Dnt': '1', 'Upgrade-Insecure-Requests': '1', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.91 Safari/537.36'}, 'pathParameters': {}, 'stageVariables': None,'path': '/'}
notice that in the requestContext, the httpMethod is ''
sanathkr commentedon Sep 26, 2017
Thanks for digging through this. Looks like SAM Local isn't passing the method in request context. Would you be able to send a PR to fix this?
Just add one line here https://github.com/awslabs/aws-sam-local/blob/8edcd3c46fa586fc307358f882005cdf278f282e/event.go#L83
ehault commentedon Sep 26, 2017
Would love to contribute! I should have a PR by tomorrow.
ehault commentedon Sep 27, 2017
Hello again, @sanathkr
I'm kinda new to public PRs, I cloned, created a branch and commited but don't have permission to push. I sadly don't have any time right now to look into this.
I also didn't see tests for event.go, so I assumed this would be the only change needed.
Here's the diff:
Cheers
resios commentedon Sep 29, 2017
This is something that is fixed by #143 : https://github.com/awslabs/aws-sam-local/pull/143/files#diff-9fb85d1ee9f1b0a59804bec41e1491feR85
kadrach commentedon Feb 8, 2018
I can see #143 was merged, but came across a similar issue today. Did this ever get resolved successfully?
chalice 1.1.0andaws-sam-localbuild from develop today.Unchanged if using
--prefix-routingoption introduced in #143.kadrach commentedon Feb 9, 2018
See also #220.
kadrach commentedon Feb 9, 2018
Tricked myself by having the wrong version of aws-sam-local on path. This issue is resolved. Apologies :)
sanathkr commentedon May 8, 2018
Can you try the latest release - https://github.com/awslabs/aws-sam-cli/releases/tag/v0.3.0? I believe this is fixed. Feel free to re-open Issue if not.
include commentedon May 10, 2018
Hi,
This is working but note currently sam-cli uses (only) Python2 and chalice uses (only) Python3.
Do not forget to
cd package && pyenv local 2.7.xbeforesam local start-api -t sam.jsonCheers,
Francisco