kestra-io/kestra · error · PebbleException

Invalid ion: {e.getMessage()}

Error message

Invalid ion: {e.getMessage()}

What it means

Thrown by 'fromIon' when FileSerde.readAll or the subsequent stream/terminal operation raises a RuntimeException or IOException. This means the content was a string/bytes but could not be parsed as valid Ion (or Kestra's row Ion format), so the deserialization failed mid-read.

Source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/FromIonFunction.java:70

        boolean allRows = args.containsKey("allRows") ? (Boolean) args.get("allRows") : false;

        try {
            Flux<Object> flux = FileSerde.readAll(new ByteArrayInputStream(ionBytes));

            if (!allRows) {
                flux = flux.take(1);
            }

            Stream<Object> data = flux.toStream();

            if (allRows) {
                return data.toList();
            }

            return data.findFirst().orElse(null);
        } catch (RuntimeException | IOException e) {
            throw new PebbleException(null, "Invalid ion: " + e.getMessage(), lineNumber, self.getName());
        }
    }
}

View on GitHub (pinned to 823fada927)

Solutions

  1. Confirm the content is actually Kestra Ion; if it is JSON, use fromJson() instead.
  2. If reading from a file, ensure the producing task wrote it in Ion format (e.g. set row encoding to ION).
  3. Inspect the source bytes to verify they are well-formed Ion before passing them to fromIon().

Example fix

# before - JSON content passed to fromIon()
rows: "{{ fromIon(readFile('data.json')) }}"
# after - match parser to format
rows: "{{ fromJson(readFile('data.json')) }}"
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the content is Ion before parsing; if it is JSON, use fromJson() instead.
# {{ (content starts with '{' or content starts with '[') ? fromJson(content) : fromIon(content) }}

Try / catch

# Pebble has no try/catch. In a wrapper task, catch RuntimeException|IOException and return null or a fallback.

Prevention

When it happens

Trigger: Passing fromIon() a string that is not valid Ion (e.g. plain CSV, JSON, or free text); truncated or corrupted Ion bytes; a file whose content is a different serialization format mislabeled as .ion.

Common situations: Reading a JSON or CSV file with fromIon() by mistake; partial file reads producing incomplete bytes; mixing up fromIon() and fromJson() for the file format at hand.

Related errors


AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14). Data as JSON: /api/errors/c4979d16051c7776. Report an issue: GitHub.