feat(sfn): support ItemReader InputType JSONL (#3602)

A Distributed Map could only read a JSON dataset: every other InputType failed
the state with "not yet implemented". JSONL now reads one item per line,
skipping blank lines, so a trailing newline is not an item.

ReaderConfig.ItemsPointer stays JSON only, as on AWS, and MaxItems truncates a
JSONL dataset the same way it truncates a JSON one.
This commit is contained in:
Ovidiu (Ovi) authored and GitHub committed 2026-09-16 09:13:51 -04:00
1 parent fc5380418e
commit ef341e1c01
3 files changed
+184 -7

No files matched your search

@@ -3077,7 +3077,7 @@ public class AslExecutor {
}
String inputType = itemReader.path("ReaderConfig").path("InputType").asText(null);
if (!"JSON".equals(inputType)) {
if (!"JSON".equals(inputType) && !"JSONL".equals(inputType)) {
throw new FailStateException("States.ItemReaderFailed",
"ItemReader InputType " + inputType + " is not yet implemented by the emulator");
}
@@ -3091,6 +3091,10 @@ public class AslExecutor {
try {
S3Object object = s3Service.getObject(bucket, key);
if ("JSONL".equals(inputType)) {
return new ResolvedMapItems(applyMaxItems(itemReader, readJsonLines(object.getData())),
MapItemsSource.ITEM_READER_ARRAY);
}
JsonNode items = objectMapper.readTree(object.getData());
items = applyItemsPointer(itemReader, items);
if (items.isObject()) {
@@ -3112,6 +3116,20 @@ public class AslExecutor {
}
}
/**
* One item per non-empty line. ReaderConfig.ItemsPointer is JSON only on AWS, so a JSONL
* dataset is always the whole file.
*/
private ArrayNode readJsonLines(byte[] data) throws IOException {
ArrayNode items = objectMapper.createArrayNode();
for (String line : new String(data, StandardCharsets.UTF_8).split("\\R")) {
if (!line.isBlank()) {
items.add(objectMapper.readTree(line));
}
}
return items;
}
private JsonNode resolveItemReaderParameters(JsonNode itemReader, JsonNode input, JsonNode context,
boolean jsonata, ObjectNode variables) throws Exception {
if (jsonata && itemReader.has("Arguments")) {