Python3.6 environment JSON decode error
I'm trying to run a lambda function locally, with the docker image set to Python3.6 For some reason, I get a weird error, even when there are no imports in the code
This is the code of the lambda function:
`def lambda_handler(event, context):
return {
'statusCode': 200,
'body': 'asd'
}`
The command I'm running:
docker run --rm -v C:\sandbox-lambda:/var/task:ro,delegated lambci/lambda:python3.6 lambda_function.lambda_handler --network="host"
The error:
START RequestId: 5765fe27-9f5b-1e2d-2c8d-a62b20632f03 Version: $LATEST
Unable to parse input as json: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
Traceback (most recent call last):
File "/var/lang/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/var/lang/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/var/lang/lib/python3.6/json/decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 2 (char 1)
END RequestId: 5765fe27-9f5b-1e2d-2c8d-a62b20632f03
REPORT RequestId: 5765fe27-9f5b-1e2d-2c8d-a62b20632f03 Init Duration: 145.84 ms Duration: 3.95 ms Billed Duration: 100 ms Memory Size: 1536 MB Max Memory Used: 26 MB
{"errorType":"JSONDecodeError","errorMessage":"Expecting property name enclosed in double quotes: line 1 column 2 (char 1)","stackTrace":[" File \"/var/lang/lib/python3.6/json/__init__.py\", line 354, in loads\n return _default_decoder.decode(s)\n"," File \"/var/lang/lib/python3.6/json/decoder.py\", line 339, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n"," File \"/var/lang/lib/python3.6/json/decoder.py\", line 355, in raw_decode\n obj, end = self.scan_once(s, idx)\n"]}
PS C:\sandbox-lambda>
You're passing --network="host" as the JSON event (which isn't valid JSON)
If you wanted to include that docker argument, you need to have it before you specify the image
See Usage for the order of arguments after the image name: https://github.com/lambci/docker-lambda#usage