kestra-io/kestra · error · IllegalVariableEvaluationException

Unknown value element type: {}

Error message

Unknown value element type: {}

What it means

Thrown by the `valueAsString` helper when an individual iteration element is a Java type that is not String, Number, Map, or null — e.g. a `Boolean`, a nested `List`, a `java.net.URI`, or an arbitrary domain object. The placeholder is `value.getClass()`. The helper only knows how to render scalars and maps; nested collections and booleans are unsupported.

Source

Thrown at core/src/main/java/io/kestra/core/runners/FlowableUtils.java:482

                List<Pair<String, String>> resolvedValues = new ArrayList<>();
                for (var entry : ((Map<String, Object>) mapValue).entrySet()) {
                    resolvedValues.add(Pair.of(entry.getKey(), valueAsString(runContext, values, entry.getValue())));
                }
                return Either.right(resolvedValues);
            }
            default -> throw new IllegalVariableEvaluationException("Unknown value type: " + values.getClass());
        }
    }

    private static String valueAsString(RunContext runContext, Object values, Object value) throws IllegalVariableEvaluationException {
        return switch (value) {
            case String stringObj -> runContext.render(stringObj);
            case Number number -> runContext.render(number.toString());
            case Map<?, ?> mapObj -> serializeAsString(runContext.render((Map<String, Object>) mapObj)); //JSON or YAML map
            case null -> throw new IllegalVariableEvaluationException(
                "Found a null value inside the iteration values=" + serializeAsString(values)
            );
            default -> throw new IllegalVariableEvaluationException("Unknown value element type: " + value.getClass());
        };
    }

    private static String serializeAsString(Object obj) throws IllegalVariableEvaluationException {
        try {
            return MAPPER.writeValueAsString(obj);
        } catch (JsonProcessingException e) {
            throw new IllegalVariableEvaluationException(e);
        }
    }

    /**
     * Returns the index of the given {@code lastTerminated} task run within {@code currentTasks},
     * matching by task ID (and optionally by parent/value via {@link #isTaskRunFor}).
     * Using this index instead of the position in the raw task-run list avoids off-by-N skipping
     * when a task produces multiple task runs (e.g. WaitFor creates one per iteration).
     *
     * @return the 0-based index, or {@code -1} if not found

View on GitHub (pinned to 823fada927)

Solutions

  1. Flatten or stringify unsupported elements before iteration: render booleans/objects to strings (`{{ v | json }}`).
  2. Restructure the data so each element is a String, Number, or Map.
  3. If iterating nested collections, iterate one level deeper or use a map transform to serialize each element to JSON.

Example fix

# before — booleans are unsupported element types
values:
  - true
  - false

# after — stringify
values: "[true, false]"  # rendered as JSON array of... still fails; instead:
values:
  - "true"
  - "false"
Defensive patterns

Strategy: validation

Validate before calling

// Stringify non-scalar/non-map elements
if (values instanceof List<?> list) {
    values = list.stream().map(v ->
        (v instanceof String || v instanceof Number || v instanceof Map<?,?>)
            ? v : MAPPER.writeValueAsString(v)
    ).toList();
}

Type guard

static boolean isSupportedElement(Object v) {
    return v instanceof String || v instanceof Number || v instanceof Map<?, ?>;
}

Prevention

When it happens

Trigger: An iteration `values` list/map whose elements are booleans, nested lists, URIs, or custom objects — e.g. `values: [true, false]` or a list containing sub-lists. Reached via both the List branch (line 456-461) and the JSON-object branch of `resolveValues`.

Common situations: Boolean flags in iteration data; arrays-of-arrays; plugin outputs that emit typed records rather than primitives; YAML literals that parse to booleans (`true`/`false`/`yes`/`no`).

Related errors


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