Skip to content

fix(#995): the two Step Functions deletes are idempotent, and DELETING is admitted unreachable - #1069

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/995-sfn-idempotent-deletes
Sep 18, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/995-sfn-idempotent-deletes

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

DeleteStateMachine and DeleteActivity refused an ARN naming nothing with StateMachineDoesNotExist / ActivityDoesNotExist. Both are real Step Functions codes — published at DescribeStateMachine, UpdateStateMachine, StartExecution, StartSyncExecution, ListExecutions and DescribeActivity — but API_DeleteStateMachine publishes exactly InvalidArn and ValidationException, and API_DeleteActivity publishes InvalidArn alone. Substrate answered them because both handlers went through the same require* helper as their published siblings, so the code arrived with the lookup rather than by a decision.

Both now parse the ARN, load directly, and answer 200 with an empty body when nothing is there.

The evidence, stated at its actual strength

This is substrate's reading of an absent code, not a published guarantee, and weaker than SNS's #992 where API_DeleteTopic states the property outright. What carries it:

  • the error list is the only thing either page says on the matter, and it omits both not-found codes;
  • the description makes an idempotent delete the behaviour a caller needs — "This is an asynchronous operation. It sets the state machine's status to DELETING and begins the deletion process. A state machine is deleted only when all its executions are completed." A caller that has issued a delete and retries cannot distinguish "already gone" from "still DELETING".

The ARN parse stays ahead of the load in both handlers, so idempotence licenses an ARN that names nothing and not a string that is not the right kind of ARN. Every InvalidArn refusal is unchanged, and a test states that reason where the idempotence is.

DELETING is not modelled, and the type stops claiming it

StateMachineState.Status' doc comment named both ACTIVE and DELETING, which API_DescribeStateMachine publishes. A tree-wide search for a Status: writer in Step Functions finds exactly one, writing "ACTIVE". Nothing can write the other: the delete removes the record synchronously, so there is no observation between ACTIVE and gone for a DELETING to occupy — which also makes StateMachineDeleting/400 unreachable at UpdateStateMachine, StartExecution and StartSyncExecution. A caller therefore cannot test a poll loop that waits for a delete to finish.

Modelling the transition is in scope for substrate as a seedable progression, but it is separate work. The limitation is stated in the type, in docs/services.md, and in a test that asserts the emulator's actual answer, so whoever models it later hits a failing assertion naming this decision rather than silently widening the enum.

The ARN tables keep both operations

The issue asked for both deletes to be removed from sfnArnStateMachineOps and sfnArnActivityOps. That would have deleted live coverage — those tables drive three other tests in which both deletes still must answer InvalidArn (malformed shape, wrong resource type, version- or alias-qualified ARN). Only the absent-resource loop changes, so the three anonymous structs collapse into a named sfnArnOpCall with an absentIsIdempotent column and the operation inventory stays in one place. Explained in full on the issue, along with two line-drift corrections and the fact that neither page states idempotence.

Because a 200 on a foreign ARN no longer proves by its status that the delete declined to act, the tests assert the state instead: the caller's own same-named resources survive every cross-account and cross-Region delete, a repeated delete leaves the name index intact and a sibling untouched, and Describe still refuses — only the delete is idempotent.

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.

Closes #995

…G is admitted unreachable

DeleteStateMachine and DeleteActivity refused an absent resource with
StateMachineDoesNotExist / ActivityDoesNotExist. Both are real Step Functions
codes, but API_DeleteStateMachine publishes exactly InvalidArn and
ValidationException and API_DeleteActivity publishes InvalidArn alone.
Substrate answered them because both handlers went through the same require*
helper as their published siblings, so the code arrived with the lookup rather
than by a decision. Both now parse the ARN, load directly, and answer 200 with
an empty body when nothing is there.

This is substrate's reading of an absent code, not a published guarantee, and
weaker evidence than SNS's #992 where API_DeleteTopic states the property
outright. The ARN parse stays ahead of the load, so idempotence licenses an ARN
that names nothing and not a string that is not the right kind of ARN.

StateMachineState.Status no longer claims DELETING. A tree-wide search for a
writer found one, writing "ACTIVE". Nothing can write the other: the delete
removes the record synchronously, so there is no observation between ACTIVE and
gone for it to occupy, which also makes StateMachineDeleting/400 unreachable.
Stated in the type, in docs/services.md and in a test asserting the emulator's
actual answer.

The shared ARN tables keep both operations, because three other tests still
require both deletes to answer InvalidArn; the three anonymous structs collapse
into a named sfnArnOpCall carrying an absentIsIdempotent column. Since a 200 no
longer proves the delete declined to act, the tests assert the state instead.

Closes #995
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 542f0f1 into main Sep 18, 2026
17 checks passed
@scttfrdmn
scttfrdmn deleted the fix/995-sfn-idempotent-deletes branch September 18, 2026 19:48
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: DeleteStateMachine and DeleteActivity refuse an absent resource with a code their pages do not publish

1 participant