fix(stepfunctions): refuse an unsupported ecs:runTask pattern before launching the task (#8545)

ecs:runTask supports request-response, .sync and .waitForTaskToken. A
.sync:2 resource used to launch the task and only then fail the state
with "Unsupported ecs:runTask mode", leaving the task running unmonitored.
The pattern is now checked before RunTask is called, and the state fails
with the same "Unsupported resource" error as other unsupported
integrations.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-11-16 00:43:26 -04:00
1 parent fc141d12d6
commit 9392bd54af
2 files changed
+20 -6

No files matched your search

@@ -1573,6 +1573,12 @@ public class AslExecutor {
// variant arrives here as the bare runTask resource and simply launches the task while the token
// future blocks for SendTaskSuccess.
if (integration.isAnySuffix("ecs", "runTask")) {
// AWS defines request-response, .sync and .waitForTaskToken for ecs:runTask, so any other
// pattern (.sync:2) is refused before a task is launched rather than after.
String suffix = integration.suffix();
if (!suffix.isEmpty() && !".sync".equals(suffix) && !".waitForTaskToken".equals(suffix)) {
throw OptimizedIntegrations.unsupported(integration);
}
// A non-null taskToken means the original resource ended with .waitForTaskToken (stripped
// upstream). Its failure semantics match .sync — a task placement failure fails the state —
// whereas request-response returns the {Tasks,Failures} envelope without failing the state.
@@ -2339,12 +2345,6 @@ public class AslExecutor {
return resp;
}
if (!".sync".equals(mode)) {
// Only request-response (""), .sync and .waitForTaskToken are valid; reject typos rather
// than silently treating an unknown suffix as .sync.
throw new FailStateException("States.TaskFailed", "Unsupported ecs:runTask mode: " + mode);
}
// .sync — wait until every launched task reaches STOPPED, then surface success or failure.
// All tasks must be polled (not just the first): with Count > 1, a failure in any task must
// fail the state, otherwise tasks beyond the first would run unmonitored. The wait is bounded