feat(stepfunctions): support Map ItemReader for S3-backed JSON datasets (#1588)

* feat(stepfunctions): support Map ItemReader for S3-backed JSON datasets

* feat(stepfunctions): support Map ItemReader for S3-backed JSON datasets

* fix(stepfunctions): surface non-array ItemReader JSON as ItemReaderFailed

* fix(stepfunctions): align ItemReader runtime failures with emulator support

* refactor(stepfunctions): remove unused state machine parameter from resolveMapItems

* fix(stepfunctions): require DISTRIBUTED mode for ItemReader maps

* fix(stepfunctions): surface unimplemented ItemReader input types as ItemReaderFailed

* fix(stepfunctions): update AslExecutorCatchTest for constructor changes

* fix(stepfunctions): align ItemReader JSON object handling with AWS

* fix(stepfunctions): support ItemReader ItemsPointer for JSON datasets

* fix(stepfunctions): align ItemReader mode and JSONata arguments with AWS

* fix(stepfunctions): preserve array item context for Key/Value-shaped data
This commit is contained in:
shrimptails-f authored and GitHub committed 2026-07-06 22:51:39 -05:00
1 parent a40dc52f4d
commit 36ef98047e
5 files changed
+1441 -33

No files matched your search

@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.services.lambda.LambdaFunctionStore;
import io.github.hectorvent.floci.services.lambda.model.InvocationType;
import io.github.hectorvent.floci.services.lambda.model.InvokeResult;
import io.github.hectorvent.floci.services.lambda.model.LambdaFunction;
import io.github.hectorvent.floci.services.s3.S3Service;
import io.github.hectorvent.floci.services.sqs.SqsJsonHandler;
import io.github.hectorvent.floci.services.stepfunctions.model.Execution;
import io.github.hectorvent.floci.services.stepfunctions.model.HistoryEvent;
@@ -76,7 +77,7 @@ class AslExecutorCatchTest {
mock(SqsJsonHandler.class),
mock(io.github.hectorvent.floci.services.cloudformation.CloudFormationQueryHandler.class),
mock(io.github.hectorvent.floci.services.ec2.Ec2Service.class),
mock(io.github.hectorvent.floci.services.s3.S3Service.class),
mock(S3Service.class),
mock(io.github.hectorvent.floci.services.ecs.EcsService.class),
mock(io.github.hectorvent.floci.services.ecs.EcsJsonHandler.class),
objectMapper,
@@ -40,6 +40,50 @@ class StepFunctionsValidateStateMachineDefinitionIntegrationTest {
+ "\\\"InputPath\\\":\\\"$.a\\\","
+ "\\\"OutputPath\\\":\\\"$.b\\\","
+ "\\\"ResultPath\\\":\\\"$.c\\\"}}}";
private static final String MAP_WITH_UNSUPPORTED_ITEM_READER_RESOURCE =
"{\\\"StartAt\\\":\\\"ProcessItems\\\",\\\"States\\\":{\\\"ProcessItems\\\":{"
+ "\\\"Type\\\":\\\"Map\\\","
+ "\\\"ItemReader\\\":{"
+ "\\\"Resource\\\":\\\"arn:aws:states:::s3:unknownOperation\\\","
+ "\\\"ReaderConfig\\\":{\\\"InputType\\\":\\\"JSON\\\"},"
+ "\\\"Parameters\\\":{\\\"Bucket\\\":\\\"map-inputs\\\",\\\"Key\\\":\\\"workers.json\\\"}"
+ "},"
+ "\\\"ItemProcessor\\\":{"
+ "\\\"ProcessorConfig\\\":{\\\"Mode\\\":\\\"DISTRIBUTED\\\",\\\"ExecutionType\\\":\\\"STANDARD\\\"},"
+ "\\\"StartAt\\\":\\\"PassItem\\\","
+ "\\\"States\\\":{\\\"PassItem\\\":{\\\"Type\\\":\\\"Pass\\\",\\\"End\\\":true}}"
+ "},"
+ "\\\"End\\\":true"
+ "}}}";
private static final String MAP_WITH_UNSUPPORTED_ITEM_READER_INPUT_TYPE =
"{\\\"StartAt\\\":\\\"ProcessItems\\\",\\\"States\\\":{\\\"ProcessItems\\\":{"
+ "\\\"Type\\\":\\\"Map\\\","
+ "\\\"ItemReader\\\":{"
+ "\\\"Resource\\\":\\\"arn:aws:states:::s3:getObject\\\","
+ "\\\"ReaderConfig\\\":{\\\"InputType\\\":\\\"UNSUPPORTED\\\"},"
+ "\\\"Parameters\\\":{\\\"Bucket\\\":\\\"map-inputs\\\",\\\"Key\\\":\\\"workers.json\\\"}"
+ "},"
+ "\\\"ItemProcessor\\\":{"
+ "\\\"ProcessorConfig\\\":{\\\"Mode\\\":\\\"DISTRIBUTED\\\",\\\"ExecutionType\\\":\\\"STANDARD\\\"},"
+ "\\\"StartAt\\\":\\\"PassItem\\\","
+ "\\\"States\\\":{\\\"PassItem\\\":{\\\"Type\\\":\\\"Pass\\\",\\\"End\\\":true}}"
+ "},"
+ "\\\"End\\\":true"
+ "}}}";
private static final String MAP_WITH_ITEM_READER_WITHOUT_DISTRIBUTED_MODE =
"{\\\"StartAt\\\":\\\"ProcessItems\\\",\\\"States\\\":{\\\"ProcessItems\\\":{"
+ "\\\"Type\\\":\\\"Map\\\","
+ "\\\"ItemReader\\\":{"
+ "\\\"Resource\\\":\\\"arn:aws:states:::s3:getObject\\\","
+ "\\\"ReaderConfig\\\":{\\\"InputType\\\":\\\"JSON\\\"},"
+ "\\\"Parameters\\\":{\\\"Bucket\\\":\\\"map-inputs\\\",\\\"Key\\\":\\\"workers.json\\\"}"
+ "},"
+ "\\\"ItemProcessor\\\":{"
+ "\\\"StartAt\\\":\\\"PassItem\\\","
+ "\\\"States\\\":{\\\"PassItem\\\":{\\\"Type\\\":\\\"Pass\\\",\\\"End\\\":true}}"
+ "},"
+ "\\\"End\\\":true"
+ "}}}";
@BeforeAll
static void configure() {
@@ -88,6 +132,43 @@ class StepFunctionsValidateStateMachineDefinitionIntegrationTest {
.body("diagnostics[0].location", equalTo("/States/X/InputPath"));
}
@Test
void unsupportedItemReaderResource_returnsFailWithSchemaError() {
given().contentType(CT).header("X-Amz-Target", TARGET)
.body("{\"definition\":\"" + MAP_WITH_UNSUPPORTED_ITEM_READER_RESOURCE + "\"}")
.when().post("/")
.then().statusCode(200)
.body("result", equalTo("FAIL"))
.body("diagnostics", hasSize(1))
.body("diagnostics[0].severity", equalTo("ERROR"))
.body("diagnostics[0].code", equalTo("SCHEMA_VALIDATION_FAILED"))
.body("diagnostics[0].location", equalTo("/States/ProcessItems/ItemReader/Resource"));
}
@Test
void unsupportedItemReaderInputType_returnsFailWithSchemaError() {
given().contentType(CT).header("X-Amz-Target", TARGET)
.body("{\"definition\":\"" + MAP_WITH_UNSUPPORTED_ITEM_READER_INPUT_TYPE + "\"}")
.when().post("/")
.then().statusCode(200)
.body("result", equalTo("FAIL"))
.body("diagnostics", hasSize(1))
.body("diagnostics[0].severity", equalTo("ERROR"))
.body("diagnostics[0].code", equalTo("SCHEMA_VALIDATION_FAILED"))
.body("diagnostics[0].location", equalTo("/States/ProcessItems/ItemReader/ReaderConfig/InputType"));
}
@Test
void itemReaderWithoutDistributedMode_isAcceptedAtDefinitionTime() {
given().contentType(CT).header("X-Amz-Target", TARGET)
.body("{\"definition\":\"" + MAP_WITH_ITEM_READER_WITHOUT_DISTRIBUTED_MODE + "\"}")
.when().post("/")
.then().statusCode(200)
.body("result", equalTo("OK"))
.body("diagnostics", hasSize(0))
.body("truncated", is(false));
}
@Test
void emptyDefinition_returns400() {
given().contentType(CT).header("X-Amz-Target", TARGET)