fix(stepfunctions): resolve the States.Format template argument like every other argument (#2963)

AslExecutor.applyIntrinsic read the format template with
unquoteString(parts.get(0)), which only stripped surrounding quotes
and otherwise took the argument literally. Every other argument goes
through resolveIntrinsicArg, which resolves $. paths and raises the
missing-argument error added in #2872. A reference path written in the
template position skipped both, so States.Format($.nope, 1) succeeded
with the literal string "$.nope" instead of resolving it.

The template argument now goes through resolveIntrinsicArg like the
rest, so a template path that matches nothing fails with
States.Runtime using the same cause format every other missing
argument already produces, and a template path that does resolve is
used as the template.

Removed the now-unused unquoteString helper.

Fixes #2927
This commit is contained in:
Olamide Kosile authored and GitHub committed 2026-09-06 13:46:17 -05:00
1 parent dec348d382
commit fa265a4a33
2 files changed
+23 -15

No files matched your search

@@ -3401,7 +3401,12 @@ public class AslExecutor {
if (parts.isEmpty()) {
throw new FailStateException("States.Runtime", "States.Format requires at least one argument");
}
String template = unquoteString(parts.get(0));
// The template position is itself an argument, not a raw literal, on real AWS: a
// reference path written there is resolved the same way every other argument is,
// and a path that matches nothing fails the state instead of formatting as the
// path string itself.
JsonNode templateArg = resolveIntrinsicArg(parts.get(0), root, context);
String template = templateArg.isTextual() ? templateArg.asText() : templateArg.toString();
StringBuilder sb = new StringBuilder();
int argIdx = 1;
for (int i = 0; i < template.length(); i++) {
@@ -3775,14 +3780,6 @@ public class AslExecutor {
return result;
}
private String unquoteString(String s) {
s = s.trim();
if ((s.startsWith("'") && s.endsWith("'")) || (s.startsWith("\"") && s.endsWith("\""))) {
return s.substring(1, s.length() - 1);
}
return s;
}
// ──────────────────────────── History helpers ────────────────────────────
/**