feat(stepfunctions): implement States.JsonMerge intrinsic (#1662)

* feat(stepfunctions): implement States.JsonMerge intrinsic

The DPS provisioning state machine uses States.JsonMerge, which AslExecutor rejected with "Unsupported intrinsic function: States.JsonMerge". Implement the shallow merge (second object's top-level fields win on conflict); reject the deep-merge form (third argument true) and non-object arguments, as AWS does. Also resolve boolean/null literal intrinsic arguments so the third argument evaluates correctly. Covered by AslExecutorJsonMergeTest.

* fix(stepfunctions): reject a non-boolean States.JsonMerge third argument

The third (deep) argument was read with JsonNode.asBoolean(), which silently
coerces null/number/string/object nodes to false, so States.JsonMerge($.a,$.b,$.x)
with a non-boolean $.x quietly performed a shallow merge instead of failing.
Validate that the resolved third argument is a boolean and raise States.Runtime
otherwise. Covered by AslExecutorJsonMergeTest.nonBooleanThirdArgumentRejected.

* fix(stepfunctions): validate JsonMerge argument types before the deep-merge flag

AWS validates the argument types of States.JsonMerge before evaluating the deep-merge
flag, so two non-objects passed with true should report "requires two JSON objects"
rather than "shallow merge only". Reorder the object-type check ahead of the deep-flag
rejection and add a precedence test.

* test(stepfunctions): adapt JsonMerge test to main's AslExecutor constructor

main's AslExecutor constructor now takes EcsService and EcsJsonHandler; pass the
two new mocks. Also generalize a comment that named a specific downstream system.

* docs: regenerate action tables

* fix(stepfunctions): thread context into States.JsonMerge intrinsic args

The intrinsic pipeline gained a context argument on main (resolveIntrinsicArg /
evaluateIntrinsic now take three parameters). Thread the surrounding case's
root/context through the three States.JsonMerge argument resolutions so the branch
compiles against current main.

* fix: align JsonMerge intrinsic failures

* fix(athena): harden compatibility query polling
This commit is contained in:
Alex Banna authored and GitHub committed 2026-07-21 12:14:35 -04:00
1 parent 024d74e5c4
commit b245632a2e
5 files changed
+192 -32

No files matched your search

@@ -5,6 +5,7 @@ import software.amazon.awssdk.services.athena.AthenaClient;
import software.amazon.awssdk.services.athena.model.*;
import software.amazon.awssdk.services.glue.GlueClient;
import java.time.Duration;
import java.time.Instant;
import java.util.UUID;
@@ -66,20 +67,12 @@ class AthenaTest {
@Test
@Order(3)
@DisplayName("Get query results returns result set")
void getQueryResults() {
// Poll until succeeded (mock mode completes immediately, real duck may take a moment)
QueryExecutionState state = QueryExecutionState.RUNNING;
int attempts = 0;
while (state == QueryExecutionState.RUNNING && attempts++ < 20) {
GetQueryExecutionResponse exec = athena.getQueryExecution(
GetQueryExecutionRequest.builder().queryExecutionId(queryExecutionId).build());
state = exec.queryExecution().status().state();
if (state == QueryExecutionState.RUNNING) {
try { Thread.sleep(500); } catch (InterruptedException ignored) {}
}
}
assertThat(state).isEqualTo(QueryExecutionState.SUCCEEDED);
void getQueryResults() throws InterruptedException {
QueryExecutionStatus status = TestFixtures.awaitAthenaQueryTerminal(
athena, queryExecutionId, Duration.ofSeconds(60));
assertThat(status.state())
.as("Athena query did not succeed: %s", status.stateChangeReason())
.isEqualTo(QueryExecutionState.SUCCEEDED);
GetQueryResultsResponse results = athena.getQueryResults(
GetQueryResultsRequest.builder()
@@ -177,4 +170,3 @@ class AthenaTest {
glue.close();
}
}
@@ -11,6 +11,7 @@ import software.amazon.awssdk.services.glue.GlueClient;
import software.amazon.awssdk.services.glue.model.*;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -92,23 +93,11 @@ class DataLakeTest {
String queryId = startResp.queryExecutionId();
// Wait for query
int attempts = 0;
QueryExecutionStatus status = null;
while (attempts < 30) {
GetQueryExecutionResponse getResp = athena.getQueryExecution(GetQueryExecutionRequest.builder()
.queryExecutionId(queryId)
.build());
status = getResp.queryExecution().status();
if (status.state() == QueryExecutionState.SUCCEEDED) break;
if (status.state() == QueryExecutionState.FAILED) {
Assertions.fail("Query failed: " + status.stateChangeReason());
}
Thread.sleep(1000);
attempts++;
}
assertThat(status.state()).isEqualTo(QueryExecutionState.SUCCEEDED);
QueryExecutionStatus status = TestFixtures.awaitAthenaQueryTerminal(
athena, queryId, Duration.ofSeconds(60));
assertThat(status.state())
.as("Athena query did not succeed: %s", status.stateChangeReason())
.isEqualTo(QueryExecutionState.SUCCEEDED);
GetQueryResultsResponse results = athena.getQueryResults(GetQueryResultsRequest.builder()
.queryExecutionId(queryId)