Repository navigation
Description
DeleteStateMachine and DeleteActivity refuse an absent resource with a code neither operation publishes, and neither models the asynchronous delete AWS documents.
Surfaced while implementing #912, which rewired every ARN-taking Step Functions operation onto a shared parser. The resolution defect is fixed there and the two *DoesNotExist codes were moved from HTTP 404 to 400 along with the rest. What #912 deliberately did not change is whether these two operations should refuse an absent resource at all, because the evidence is an absence from a published error list rather than an explicit idempotence sentence, and that deserves its own argument.
What AWS publishes
API_DeleteStateMachine lists exactly two errors:
| Code | Status |
|---|---|
InvalidArn |
400 |
ValidationException |
400 |
StateMachineDoesNotExist is not among them, although it appears on API_DescribeStateMachine, API_UpdateStateMachine, API_StartExecution, API_StartSyncExecution and API_ListExecutions. The page's description also states the delete is asynchronous and that the state machine's status becomes DELETING:
Deletes a state machine. This is an asynchronous operation. It sets the state machine's status to
DELETINGand begins the deletion process.
API_DeleteActivity lists exactly one error, InvalidArn/400 — not ActivityDoesNotExist, which is one of only two errors on API_DescribeActivity. Its success is documented as:
If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.
What substrate answers today
After #912, deleteStateMachine (emulator/stepfunctions_plugin.go) answers StateMachineDoesNotExist/400 and deleteActivity answers ActivityDoesNotExist/400 for a well-formed ARN naming nothing. Both codes are real Step Functions codes at real Step Functions operations — just not at these two.
Why the absence is not conclusive on its own
The SNS precedent (#992) had a published idempotence sentence to lean on: API_DeleteTopic's "This action is idempotent, so deleting a topic that does not exist does not result in an error." Here there is no such sentence in either direction — the pages simply do not list the code. Two readings are open:
- The list is exhaustive, per
CommonErrors' framing, so an absent resource is a 200 with an empty body and the delete is idempotent. This is the reading the error list supports literally. - The list is incomplete, and AWS does refuse. Nothing on either page says so, and the argument rests only on the code existing elsewhere in the service.
Reading 1 also fits the documented asynchronous delete: a caller that has already issued a delete and retries has no way to distinguish "already gone" from "still DELETING", which is exactly the situation an idempotent delete exists for.
Adjacent, and part of the same decision
StateMachineDeleting — "The specified state machine is being deleted. Execution will not be started or updated." — is published at API_UpdateStateMachine, API_StartExecution and API_StartSyncExecution, and substrate models no DELETING status at all: deleteStateMachine removes the record synchronously, so nothing can ever observe the transition. Whether to model the status is the same question as whether the delete is idempotent, since a status a caller can observe is the only thing that makes a second delete distinguishable from the first.
Acceptance criteria
- Decide, and record in
docs/services.md, whetherDeleteStateMachineon an absent state machine andDeleteActivityon an absent activity are refusals or 200s, and state which of the two readings above is being taken and why. The answer must be labelled substrate's reading, since neither page settles it. - Whichever is chosen, the two operations answer alike — an absent state machine and an absent activity cannot disagree about whether a delete is idempotent.
-
InvalidArn/400 remains the answer for a malformed ARN, a non-statesARN, and an ARN of the wrong resource type at each operation (already true after Eleven Step Functions operations resolve a resource by the ARN's last segment plus the caller's own account and Region #912). - Decide separately whether the
DELETINGstatus is modelled, and whetherStateMachineDeleting/400 is then answered atUpdateStateMachine,StartExecutionandStartSyncExecution. If it is not modelled,docs/services.mdsays so, with the reason — a synchronous delete has no observable transition. - Behavioural tests over the wire through
emulator.StartTestServer, with every ARN taken from aCreateStateMachine/CreateActivityresponse per cfn: the aws:cloudformation:* stamp covers EC2 only, so the rest of a stack is unstamped #765: a second delete of the same resource; a delete of a never-created name; and a delete whose ARN names another account or Region, which must not touch the caller's same-named resource (the Eleven Step Functions operations resolve a resource by the ARN's last segment plus the caller's own account and Region #912 guarantee, asserted here because a delete is the damaging direction). -
CHANGELOG.mdunder## [Unreleased].
Provenance
API_DeleteStateMachine, API_DeleteActivity, API_DescribeActivity, API_UpdateStateMachine and API_StartExecution error lists, read in full while researching #912. Every Step Functions error on all eleven pages fetched is HTTP 400.
Activity
fix(stepfunctions): an ARN addresses the resource it names (#912) (#997)
scttfrdmn commentedon Sep 18, 2026
Premise corrections before the PR opens
Three things in the body are off, and one of the acceptance criteria would have destroyed coverage if followed literally. Recording them here so the divergence is on the issue rather than buried in a CHANGELOG bullet.
1. Line drift. The citations are two and six lines low respectively:
deleteStateMachine's refusal isstepfunctions_plugin.go:470/:479, not:471/:480, anddeleteActivity's is:1038/:1049, not:1032/:1040.2. Neither page states idempotence. The body reads
API_DeleteStateMachine's "This is an asynchronous operation. It sets the state machine's status toDELETINGand begins the deletion process." as a published idempotence guarantee. It is not one — AWS never says a second delete succeeds. What actually carries the change is weaker and worth stating as such:StateMachineDoesNotExist/ActivityDoesNotExist— both of which are real Step Functions codes, published atDescribeStateMachine,UpdateStateMachine,StartExecution,StartSyncExecution,ListExecutionsandDescribeActivity, just not here;DELETING".So this is substrate's reading of an absent code, and it is materially weaker evidence than #992's SNS
DeleteTopic, whose page states the property outright. The code comment,docs/services.mdand the CHANGELOG all say so rather than claiming AWS published it.Why substrate answered the unpublished code at all: both deletes went through the same
require*helper as their five and one published siblings, so the code arrived with the lookup rather than by a decision. The fix loads directly and keeps the ARN parse ahead of the load, so everyInvalidArnrefusal survives.3.
DELETINGis documented but unreachable — and stays that way.stepfunctions_types.go:220claimedStateMachineState.StatuscarriesACTIVEorDELETING. A tree-wide grep for aStatus:writer in Step Functions finds exactly one, and it writes"ACTIVE". Nothing can writeDELETING: the delete removes the record synchronously, so there is no observation betweenACTIVEand gone for the value to occupy.StateMachineDeleting/400 — published atUpdateStateMachine,StartExecutionandStartSyncExecution— is unreachable for the same reason.Modelling the transition is genuinely in scope for substrate (it is a seedable, observation-counted progression, exactly the shape the scope note in
CLAUDE.mddescribes), but it is separate work. This PR states the limitation in the type's doc comment, indocs/services.mdunder TheDELETINGstatus is not modelled, and in a test that asserts the emulator's actual answer, so whoever models it later hits a failing assertion naming this decision instead of silently widening the enum.4. The acceptance criterion about the ARN tables is wrong and was not followed. It asks that both deletes "come out of
sfnArnStateMachineOps(stepfunctions_arn_test.go:157-172) andsfnArnActivityOps(:174-185)". Removing them would have deleted live coverage: those two tables drive three other tests in which both deletes still must answerInvalidArn— the malformed-shape sweep, the wrong-resource-type sweep, and the version/alias-qualified sweep. Only the absent-resource loop changes.The tables therefore keep both operations and gain a column instead. The three anonymous structs collapse into one named type:
DeleteStateMachineandDeleteActivitycarryabsentIsIdempotent: true, and both absent-resource loops branch on it to assert an empty error code and a200. The operation inventory stays in one place, which is the property that made those tables worth having.The closing assertion at
:273-277did need the restructuring the body predicted, and for the reason it gives: a200on a foreign ARN must still not touch the caller's own resource. Before this change the refusal itself proved the delete had not acted; now nothing about the status does, so that assertion is the only thing carrying it. Its comment now says so.fix(#995): the two Step Functions deletes are idempotent, and DELETIN…