Skip to content

fix(#996): StartSyncExecution refuses a workflow type, and a definition is checked when it is stored - #1070

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/996-sfn-sync-type-not-supported
Sep 18, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/996-sfn-sync-type-not-supported

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

StartSyncExecution answered InvalidDefinition/400 for a STANDARD state machine. That is a real Step Functions code — published at CreateStateMachine and UpdateStateMachine, where a definition arrives in the request — but not on this page and not about this fact. API_StartSyncExecution publishes nine errors, all 400, and states the restriction outright: "StartSyncExecution is not available for STANDARD workflows."

It now answers StateMachineTypeNotSupported/400, "State machine type is not supported.", with the rejected type appended because the published sentence does not say which type was refused.

The second InvalidDefinition was the more interesting half

The same handler answered the same code again, for a stored definition it could not parse — and that path was live. Neither createStateMachine nor updateStateMachine checked the definition at all; both stored whatever string arrived. So substrate could accept a definition, report 200, and then be unable to execute it, reporting that to the caller as the caller's fault.

Both now answer InvalidDefinition/400, "The provided Amazon States Language definition is not valid.", for a definition that is empty, is not valid JSON, or does not describe a JSON object — and store nothing when they do.

CloudFormation was producing exactly that shape

DefinitionString is a CloudFormation string property. deployStepFunctionsStateMachine passed it through marshalToJSON, which quotes and escapes a string that is already the document, so every AWS::StepFunctions::StateMachine deployed from a DefinitionString stored a JSON string literal rather than an ASL object — and its executions failed for a reason the template author could do nothing about. cfn_intrinsics_test.go:628 is that template.

The string is now passed through unchanged; the marshal is kept for anything that is not a string, since an unresolved intrinsic arrives as a map. The sibling object-valued Definition property is still not read at all, and is filed.

Both residual paths become unreachable, and both are stated

  • In startSyncExecution, an unreadable stored definition is now a 500 through Go's error return rather than an AWSError. It means substrate wrote something it cannot read, or replayed an event log predating the validation, and that is not the caller's fault.
  • In startExecution it stays an execution-level failure — the shape an asynchronous start has to use — but the error name changes from InvalidDefinition, an API error code, to States.Runtime, the published Amazon States Language name for an execution that failed due to an exception that could not be processed.

What is not checked

Only that substrate can read the definition back. {} is accepted although AWS refuses it: the ASL requirements — a string field StartAt, an object field States, and StartAt naming one of those states — are a separate body of rules, filed separately. docs/services.md states the boundary so a 200 here is not read as ASL approval, and a test pins it.

This is also where the page itself draws the line, which is the only guidance either page gives: "Error codes are reserved for errors that prevent your execution from running, such as permissions errors, limit errors, or issues with your state machine code and configuration." An unreadable definition is an issue with the state machine's code, so AWS puts it on the error-code side — while publishing no code for it, because AWS would never have stored such a definition. Checking on the way in is the only reading that leaves both sides consistent.

docs/services.md also records that AWS's sync- prefixed endpoint host appears nowhere on this page, and that substrate does not model it — the acceptance criterion asked for the note either way.

Tests

Six, in a new stepfunctions_definition_test.go, all over the wire with every ARN taken from a create response per #765 except the CloudFormation one, which routes through the registry the deployer itself dispatches into because that deploy is in-process. A STANDARD state machine answers the new code and the old code is asserted absent; an EXPRESS one still runs; nine bad definitions are refused at create and at update with the stored definition asserted unmoved; four ASL-nonconformant-but-readable definitions are accepted, recording the boundary; and a DefinitionString template round-trips its definition and executes.

Verification

gofmt, go build, go vet, golangci-lint run ./... (0 issues), the race suite on both toolchains, the docs reference and authz checks, npm --prefix docs run build, the e2e module, and scripts/check-discarded-unmarshal.sh all pass. Coverage: 85.4% emulator / 84.9% total, above the 85.1%/84.6% floor.

Premise corrections posted on the issue before this opened, including that acceptance criterion 3's "demonstrate it is unreachable" option was unavailable, the CloudFormation producer, and the four adjacent findings filed separately.

Closes #996

…on is checked when it is stored

StartSyncExecution answered InvalidDefinition/400 for a STANDARD state machine.
That is a real Step Functions code, published at CreateStateMachine and
UpdateStateMachine where a definition arrives in the request, but not on this page
and not about this fact. API_StartSyncExecution publishes nine errors, all 400,
and states the restriction outright: "StartSyncExecution is not available for
STANDARD workflows." It now answers StateMachineTypeNotSupported/400.

Neither createStateMachine nor updateStateMachine checked the definition at all,
which is why the same code appeared twice in the same handler. Both stored
whatever string arrived, so substrate could accept a definition, report 200, and
then be unable to execute it, reporting that to the caller as the caller's fault.
Both now answer InvalidDefinition/400 for a definition that is empty, is not valid
JSON, or does not describe a JSON object, and store nothing when they do.

The CloudFormation deployer was a live producer of exactly that. DefinitionString
is a CloudFormation string property and the deployer marshaled it to JSON, quoting
and escaping a string that was already the document, so every
AWS::StepFunctions::StateMachine deployed from one stored a JSON string literal
rather than an ASL object. The string is now passed through unchanged.

Both residual paths are now unreachable and are stated rather than deleted: in
startSyncExecution an unreadable stored definition is a 500 through the error
return rather than an AWSError, and in startExecution it stays an execution-level
failure but the error name becomes States.Runtime, the published ASL name, rather
than an API error code.

What is checked is narrower than what AWS checks and docs/services.md says so:
ASL conformance is not validated, so "{}" is accepted although AWS refuses it.
docs/services.md also records that AWS's sync- endpoint host appears nowhere on
this page and that substrate does not model it.

Closes #996
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.30769% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
emulator/stepfunctions_plugin.go 78.57% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 70071bc into main Sep 18, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/996-sfn-sync-type-not-supported branch September 18, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Step Functions: StartSyncExecution answers InvalidDefinition where AWS names StateMachineTypeNotSupported

1 participant