ManageIQ / floe

Floe is a runner for Amazon States Language workflows
Apache License 2.0
0 stars 5 forks source link

Validate that state machine input is valid JSON #227

Closed agrare closed 2 months ago

agrare commented 2 months ago

When running a workflow validate that the state-machine input is valid JSON. We were a little lax with specs passing Hashes in for convenience but it isn't hard to ensure we're passing JSON in to context input.

When running with ASL passing invalid input:

$ aws stepfunctions --endpoint-url http://localhost:8083 start-execution --state-machine-arn arn:aws:states:us-east-1:123456789012:stateMachine:Pass --input 'foo'

An error occurred (InvalidExecutionInput) when calling the StartExecution operation: Invalid State Machine Execution Input: 'Unrecognized token 'foo': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
 at [Source: (String)"foo"; line: 1, column: 4]'

With this PR:

$ exe/floe examples/workflow.asl 'foo'
Invalid State Machine Execution Input: unexpected token at 'foo': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
Fryguy commented 2 months ago

I like how it matches the simulator :+1:

agrare commented 2 months ago

@Fryguy what do you think of this, something that we want to do?

miq-bot commented 2 months ago

Checked commit https://github.com/agrare/floe/commit/0698fcfb6129268293193087b950284d32855861 with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint 15 files checked, 0 offenses detected Everything looks fine. :+1:

Fryguy commented 2 months ago

Yes I think this is something we want to do. Actually had a few questions of we can chat about it.