can't succesfully run a statemachine with local lambdas
See original GitHub issueHi,
I’m unable to execute a single ‘hello world’ python lambda with localstack and stepfunctions-local.
The lambda is working as expected:
aws --endpoint-url=http://localhost:4574 lambda invoke --function-name lambda1 outfile.txt && cat outfile.txt { "StatusCode": 200 } Hello from Lambda
Then created a statemachine that uses the ARN of ‘lambda1’:
aws stepfunctions --endpoint http://localhost:4584 create-state-machine --role-arn arn:aws:iam::000000000000:role/service-role/MyRole --name successmachine --definition '{"Comment": "Test Step Function","StartAt": "SuccessLambda","States": {"SuccessLambda": {"Type": "Task","Resource": "arn:aws:lambda:us-east-1:000000000000:function:lambda1","Next": "EndState"},"EndState": {"Type": "Pass","End": true}}}'
But after starting an execution and grabbing the details of the execution-arn:
aws stepfunctions --endpoint http://localhost:4584 get-execution-history --execution-arn arn:aws:states:local:000000000000:execution:successmachine:14410b5c-ff6b-4a6c-a1a6-88c06a1fc39c { "events": [ { "timestamp": 1526997500.206, "executionStartedEventDetails": { "input": {} }, "type": "ExecutionStarted", "id": 1, "previousEventId": 0 }, { "timestamp": 1526997500.208, "type": "TaskStateEntered", "id": 2, "stateEnteredEventDetails": { "input": {}, "name": "SuccessLambda" }, "previousEventId": 1 }, { "timestamp": 1526997500.208, "lambdaFunctionScheduledEventDetails": { "input": {}, "timeoutInSeconds": 99999999 }, "type": "LambdaFunctionScheduled", "id": 3, "previousEventId": 2 }, { "timestamp": 1526997500.209, "type": "LambdaFunctionStarted", "id": 4, "previousEventId": 3 }, { "lambdaFunctionFailedEventDetails": { "cause": "SyntaxError", "error": "Unexpected token H in JSON at position 0" }, "timestamp": 1526997500.247, "type": "LambdaFunctionFailed", "id": 5, "previousEventId": 4 }, { "executionFailedEventDetails": { "cause": "SyntaxError", "error": "Unexpected token H in JSON at position 0" }, "timestamp": 1526997500.248, "type": "ExecutionFailed", "id": 6, "previousEventId": 5 } ] }
I’m not getting the clue of the JSON error. Any help is appreciated!
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
I believe I know why the error is happening, since I’m also having this problem:
What’s going into the output.txt file is trying to be parsed as JSON by the state machine. But, what’s going into the output.txt file is:
And the JSON parser’s barfing on the ‘H’. In my case, it was barfing on an S, which was the first character of my output.txt file.
I don’t know enough about State Machines to know if this is a contract I’m breaking on my end, or if stepfunctions-local needs to support plain text in lambda outputs (if someone with more experience could chime in), but at least there’s a why now.
From what I can tell, output.txt is the log of the lambda function, not the return of the lambda function, so I’m not sure why it’s being parsed as JSON.
Edit: It’s println statements. Don’t println in your Lambdas, even for debugging.
Hi @Azuaron
The
output.txt
file will contain the result of the lambda, not the logs. At least for NodeJS lambdas. I guess it is the same behaviour for all.@RutgerBeyen your issue should be solved now. We released a new version last week which I hope solved it. If you have some time to retry, please give us some update.