-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate that the workflow payload is correct #136
Conversation
lib/floe/workflow/states/pass.rb
Outdated
@@ -13,6 +13,9 @@ def initialize(workflow, name, payload) | |||
@end = !!payload["End"] | |||
@result = payload["Result"] | |||
|
|||
raise Floe::InvalidWorkflowError, "Missing \"Next\" field in state [#{name}]" if @next.nil? && !@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want a check whether End is actually defined since above we only do !!
, meaning the key may not exist? Not sure if that actually matters or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was intentional actually, End
missing implicitly means the state is not a terminal state which means Next
is required.
e3b12c9
to
101276e
Compare
d790c24
to
83dc861
Compare
Why is this WIP? Maybe we should move the criteria into the parent issue? and add check boxes? |
Yes I was seeing how far I could get through all of the rules but I think this is in a pretty good spot, I'll move the list to the parent issue and take this out of WIP |
bd48efe
to
a9decfa
Compare
Okay I wanted to get the Next state checks for Choice done, have added that now |
fbf0dc1
to
33d5ca5
Compare
Are there any ordering issues here? That is, are the states validated as they are being processed, and if so, could a state defined after a reference to it cause issues? For example, I see the Choice state validates the "Default", but what if the Default state is defined after the Choice state. I feel like that is a common layout and would have been caught in specs, but the way I'm reading the code, it feels like it could still happen? |
That's why we're validating the payload rather than the parsed states objects when checking for things like "does Default exist in States" |
Oh I see, so for https://github.com/ManageIQ/floe/pull/136/files#diff-76feb017cc942fa02bf72a61cb066c70342a42039ace6610b861b9de0a5463a9R52, the payload of the higher order workflow is already parsed and validated at this point. Thanks 👍 |
super-super-minor, but it makes me wonder if the method should be named |
Possibly? I was thinking there could be a number of things that we are validating and the raw payload is just one of them though |
8240c85
to
68d47ee
Compare
68d47ee
to
8b0590d
Compare
Checked commit agrare@8b0590d with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint |
Added - Prefix pod names with 'floe-' (#132) - Validate that the workflow payload is correct (#136) Fixed - Fix issue where certain docker image names cannot be pod names (#134) - Fix uninitialized constant RSpec::Support::Differ in tests (#137) - Handle ImagePullErr/ImagePullBackOff as errors (#135) Changed - Add task spec helper (#123) - Rename State#run_wait to just #wait (#139) - Refactor the Podman runner to be a Docker subclass (#140)
part of: #130
Rules from ASL spec https://states-language.net/
Top-level fields
States
Transitions
Timestamps
Data
Reference Paths
Payload Template
Intrinsic Functions
There are more...
#130