Repository navigation
fix(#1073): a definition that reads back and cannot run is refused - #1102
Merged
Merged
Conversation
#996 made CreateStateMachine and UpdateStateMachine check that a definition was non-empty, valid JSON, a JSON object and free of wrongly-typed members, and stopped there — so `{}` created a state machine and answered 200, as did a StartAt naming no state and a Next in one Parallel branch pointing into another. Fourteen structural rules now apply, each resting on a sentence AWS publishes, with the message naming the offending state and field. The boundary is structure over semantics: a rule exists only where a published sentence makes the document malformed regardless of any input, so a Next on a Succeed state is accepted (only End is published for that type) and everything that depends on a run stays unchecked. docs/services.md lists what is left out. Provenance: the issue's three capitalised-"MUST" sentences are states-language.net, not an AWS page; the rules are cited to amazon-states-language-state-machine-structure.html and the state pages instead. The Choice page's "the Next field can appear only in a top-level Choice Rule" is a trap the issue's rule list omits — a nested Next is refused where it stands rather than resolved and accepted. ItemProcessor is added to ASLState, contrary to the issue's claim that no schema widening is needed: AWS marks it Required, lists Iterator under deprecated fields, and recommends Iterator to Step Functions Local. Either spelling is accepted and both together refused. aslRunMap read Iterator alone, so an ItemProcessor Map iterated zero times and returned an empty array; both writers now read ASLState.mapWorkflow. Closes #1073
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CreateStateMachineandUpdateStateMachinechecked four things about a definition after #996 — non-empty, valid JSON, a JSON object, no wrongly-typed member — and nothing about whether the document named a runnable state machine. So{}created a state machine and answered200, and so did aStartAtnaming no state, a state with noType, and aNextin oneParallelbranch pointing into another.Fourteen structural rules now apply at both writers, each resting on a sentence AWS publishes, and each message names the offending state and field — a caller fixing a generated document cannot act on "The provided Amazon States Language definition is not valid."
Statespresent and non-empty (absent and{}answer different messages, the distinction #1062 needed for WAFv2'sAddresses);StartAtnaming a member of it; a publishedTypeon every state;Endrefused onChoice/Succeed/Failand exactly one ofNext/Endrequired on the other five;Choicesnon-empty with aNexton every top-level rule;Branchespresent on aParallel; aMapcarrying exactly one sub-state-machine; and every transition —Next,Catch[].Next, a rule'sNext,Default— resolving inside its ownStatesobject, which is what refuses a branch that transitions out of itself.State names are walked in sorted order, so a definition with two faults reports the same one on every run. A map range would have made the refusal a coin flip and the event log unreplayable.
The boundary
Structure, not semantics: a rule exists only where a published sentence makes the document malformed regardless of any input. So a
Nexton aSucceedorFailstate is accepted although it can never be taken — onlyEndis published for those types, and borrowing the rest by analogy is what #671 forbids. A field a state type does not support is invisible, becauseASLStateis one flat struct carrying every type's members, apart from the three cases the pages name outright. Everything that depends on a run stays unchecked.docs/services.mdlists each of these, plus the 1 MB definition-size quota substrate does not measure, replacing the paragraph that said only that conformance was unchecked.Provenance corrections (posted on the issue before this PR opened)
amazon-states-language-state-machine-structure.htmlor to the state type's own page, in AWS's words.Choicepage publishes that "theNextfield can appear only in a top-level Choice Rule", andChoiceRulemodels aNexton every nested rule. A validator written to the acceptance criteria as phrased would have resolved thatNextand accepted the document AWS refuses; it is refused where it stands instead.ItemProcessorhad to be added toASLState, contrary to the issue's claim that no schema widening is needed. AWS marks it "(Required)", listsIteratorunder "Deprecated fields", and then recommendsIteratorto Step Functions Local — exactly the class of tool substrate is. So either spelling is accepted and both together refused.cfn_intrinsics_test.go:628, not:620, and it is the only one in the corpus.Fixed in passing
aslRunMapreadIteratoralone, so aMapwritten withItemProcessoriterated zero times and returned an empty array — a silently wrong answer rather than a refusal. Validator and executor now both readASLState.mapWorkflow, and a newStartSyncExecutiontest iterates anItemProcessorMapover three items.Verification
Nine-command gate green; coverage 85.7% emulator / 85.2% total, above the 85.5%/85.0% floor. A 28-case refusal table runs at both writers, asserting code, status, AWS's message, the fault in the decoded
Message, and that nothing was stored or moved; an 11-document acceptance test states what must still create;TestSFNASL_TwoFaultsReportTheSameOneEveryTimeasserts a byte-identical body across twelve runs.Closes #1073