-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Regression: Event is not UTF-8 encoded when testing lambda locally #2494
Comments
I can reproduce this issue. I will investigate it. |
I had a same issue like you. Encrypted Json Creator
Encrypted Your example json file
lambda_function.py
|
I can confirm the same error whenever the body contains any character that cannot be encoded into Latin-1. As already mentioned, the issue is related to the |
Thanks for reporting this! As @eduardomourar mentioned, the issue is |
This has been fixed in 1.17.0: % sam --version
SAM CLI, version 1.17.0
% sam local invoke HelloWorldFunction -e events/event.json
Invoking app.lambda_handler (python3.8)
Skip pulling image and use local one: amazon/aws-sam-cli-emulation-image-python3.8:rapid-1.17.0.
Mounting /Users/rehnc/Desktop/tmp/sam-app/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container
START RequestId: c6276e1b-60ec-46a2-9e6c-ddc361ba2fc1 Version: $LATEST
END RequestId: c6276e1b-60ec-46a2-9e6c-ddc361ba2fc1
REPORT RequestId: c6276e1b-60ec-46a2-9e6c-ddc361ba2fc1 Init Duration: 0.13 ms Duration: 86.39 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 128 MB
{"statusCode": 200, "body": "{\"message\": \"hello world\"}"} |
Description:
Passing a non-Latin body to
sam local invoke
produces aUnicodeEncodeError
.My guess is the changes from #2281 might be involved (cc @awood45).
Steps to reproduce:
Unfortunately I haven't yet had time to produce a minimal repo but the command line I am using is:
Event JSON file:
Observed result:
Stack trace
As best I can tell, the issue appears to be the event is passed to
requests.post
(as introduced by 57ef284) where it is assumed to be encoded as Latin-1.Expected result:
This used to work without error (until presumably GitHub updated the version of sam-cli deployed on their Actions image).
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: Whatever is currently deployed on GitHub actionsThe text was updated successfully, but these errors were encountered: