mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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:
1 parent
dec348d382
commit
fa265a4a33
2 files changed
+23
-15
No files matched your search
+17
-6
@@ -87,15 +87,26 @@ class AslExecutorIntrinsicMissingArgumentTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* A reference path in the format template position is left as written rather than resolved, so
|
||||
* it never reaches the argument check. Real AWS and Step Functions Local resolve it and fail
|
||||
* here. That is a separate gap from issue #2870 and is tracked by issue #2927.
|
||||
* A reference path in the format template position is resolved the same as every other
|
||||
* argument, matching real AWS and Step Functions Local. Fixes issue #2927.
|
||||
*/
|
||||
@Test
|
||||
void aReferencePathAsTheFormatTemplateIsStillTakenLiterally() throws Exception {
|
||||
var resolved = resolve("{\"v.$\":\"States.Format($.nope, 1)\"}", "{\"other\":1}");
|
||||
void aReferencePathAsTheFormatTemplateIsResolvedAndFailsWhenItMatchesNothing() throws Exception {
|
||||
var failure = assertThrows(AslExecutor.FailStateException.class,
|
||||
() -> resolve("{\"v.$\":\"States.Format($.nope, 1)\"}", "{\"other\":1}"));
|
||||
|
||||
assertEquals("\"$.nope\"", resolved.path("v").toString());
|
||||
assertEquals("States.Runtime", failure.error);
|
||||
assertEquals("The function 'States.Format($.nope, 1)' had the following error: "
|
||||
+ "The JsonPath argument for the field '$.nope' could not be found in the input "
|
||||
+ "'{\"other\":1}'", failure.cause);
|
||||
}
|
||||
|
||||
/** A reference path in the template position that does resolve is used as the template. */
|
||||
@Test
|
||||
void aReferencePathAsTheFormatTemplateThatResolvesIsUsedAsTheTemplate() throws Exception {
|
||||
var resolved = resolve("{\"v.$\":\"States.Format($.tpl, 1)\"}", "{\"tpl\":\"n={}\"}");
|
||||
|
||||
assertEquals("\"n=1\"", resolved.path("v").toString());
|
||||
}
|
||||
|
||||
/** The whole expression is named, not the inner function that took the failing argument. */
|
||||
|
||||
Reference in new issue
Block a user