ManageIQ / floe

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

Pass full path name to State.new for better errors #229

Closed kbrock closed 2 months ago

kbrock commented 2 months ago

Overview

statelint passes around the path to the states instead of just the name.

If we pass a full path to State and ChoiceRule we can improve validations

I want to go through each of the states to check all fields, but that just fixed up the existing errors and added a little bit of structure to help me fix ChoiceState

Changes:

- State requires ErrorEquals
+ States.State.Retry.0 does not have required field "ErrorEquals"
- State requires ErrorEquals
+ States.State.Retry.0 does not have required field "ErrorEquals"
- Choice state must have "Choices"
+ States.Choice1 does not have required field "Choices"
- "Choices" must be a non-empty array
+ States.Choice1 field "Choices" must be a non-empty array
- "Choices" must be a non-empty array
+ States.Choice1 field "Choices" must be a non-empty array
- "Default" not in "States"
+ States.Choice1 field "Default" value "MissingState" is not found in "States"
- Missing field "States"
+ State Machine does not have required field "States"
- Invalid state type: [Invalid]
+ States.FirstState field "Type" value "Invalid" is not valid
- Missing field "StartAt"
+ State Machine does not have required field "StartAt"
- "StartAt" not in the "States" field
+ State Machine field "StartAt" value "Foo" is not found in "States"
- Missing "Type" field in state [FirstState]
+ States.FirstState does not have required field "Type"
- State name [#{truncated_state_name}] must be less than or equal to 80 characters
+ States field "Name" value "#{state_name}" must be less than or equal to 80 characters
- Invalid resource scheme [invalid]
+ States.FirstState field "Resource" value "invalid://foo" Invalid resource scheme [invalid]
kbrock commented 2 months ago

update:

kbrock commented 2 months ago

update:

agrare commented 2 months ago

I like this a lot, can you post an example error in the description of what it looked like before and after this change?

kbrock commented 2 months ago

@agrare This doesn't do much, it just passes around the name. Now that I know this is a viable direction, I have updated #209 to include the before and afters

kbrock commented 2 months ago

update:

kbrock commented 2 months ago

update:

update:

kbrock commented 2 months ago

update:

kbrock commented 2 months ago

update:

update:

update:

kbrock commented 2 months ago

update:

update:

miq-bot commented 2 months ago

Checked commits https://github.com/kbrock/floe/compare/8ca4c222dd7918530bfb9f8c22c992897b54280a~...b485de6078b1f994af36d945c916f1962c9f3561 with ruby 3.1.5, rubocop 1.56.3, haml-lint 0.51.0, and yamllint 17 files checked, 0 offenses detected Everything looks fine. :star: