ManageIQ / floe

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

Fix Input/Output handling for Pass, Choice, Succeed states #225

Closed agrare closed 2 months ago

agrare commented 2 months ago

Introduced by https://github.com/ManageIQ/floe/pull/191/files#diff-04416988853398624310337389715edeb1fed6c963a0a2a41ef882df8166dd6e

We're missing proper input processing for the Pass state if there is no Result attribute:

$ aws stepfunctions --endpoint-url http://localhost:8083 create-state-machine --name Pass --role-arn "arn:aws:iam::012345678901:role/DummyRole" --definition "{\"Comment\": \"Using Pass State\", \"StartAt\": \"Pass\", \"States\": {\"Pass\": {\"Type\": \"Pass\", \"End\": true, \"InputPath\": \"$.colors\"}}}"
$ aws stepfunctions --endpoint-url http://localhost:8083 start-execution --state-machine-arn arn:aws:states:us-east-1:123456789012:stateMachine:Pass --input '{"colors": "red"}'
$ aws stepfunctions --endpoint-url http://localhost:8083 describe-execution --execution-arn arn:aws:states:us-east-1:123456789012:execution:Pass:4747e8dd-c3ab-4124-bb45-1d7337018ddb
{
    "executionArn": "arn:aws:states:us-east-1:123456789012:execution:Pass:4747e8dd-c3ab-4124-bb45-1d7337018ddb",
    "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:Pass",
    "name": "4747e8dd-c3ab-4124-bb45-1d7337018ddb",
    "status": "SUCCEEDED",
    "startDate": "2024-06-19T12:59:05.702000-04:00",
    "stopDate": "2024-06-19T12:59:05.706000-04:00",
    "input": "{\"colors\": \"red\"}",
    "inputDetails": {
        "included": true
    },
    "output": "\"red\"",
    "outputDetails": {
        "included": true
    }
}

We should be getting "red" as the output, but currently we return the entire input payload:

Failures:

  1) Floe::Workflow::States::Pass#run_nonblock! Without Results Uses input
     Failure/Error: expect(ctx.output).to eq("red")

       expected: "red"
            got: {"color"=>"red"}

       (compared using ==)

       Diff:
       @@ -1 +1 @@
       -"red"
       +"color" => "red",

     # ./spec/workflow/states/pass_spec.rb:101:in `block (4 levels) in <top (required)>'
kbrock commented 2 months ago

I will put together a test with a combination of result, input path, result path, output path.

see how the values go.

I'm wondering if I screwed up and the input path IS processed for the output

Also noticed that Success has input/output path and we do not handle.

kbrock commented 2 months ago

Note: Merge #214 before merging this

miq-bot commented 2 months ago

Checked commits https://github.com/agrare/floe/compare/f7a0d9308ec1817fcbd3f84736df2c94508c5f21~...7eecf93e1b074a5b0e4ab458b60682fb7ae18a3e with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint 6 files checked, 0 offenses detected Everything looks fine. :trophy:

Fryguy commented 2 months ago

Clarifying question - In the OP I see

"output": "\"red\"",

but then the comment right after said

We should be getting "red" as the output, but currently we return the entire input payload:

I think this is supposed to be that we should be getting \"red\" as the output (with the quotations), as that's valid JSON. This overlaps with my concerns in https://github.com/ManageIQ/floe/pull/222#issuecomment-2182948069 as well.