kestra-io/kestra · error · PebbleException
The 'loopOutputs' function expects 'outputs' to be a list.
Error message
The 'loopOutputs' function expects 'outputs' to be a list.
What it means
The loopOutputs() function checks that the 'outputs' argument is an instance of List<?>. If it is non-null but not a list (e.g. a Map, a String, or a single Object), this type-check error fires. Loop task iteration outputs are expected to be a list of per-iteration output maps.
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/LoopOutputsFunction.java:42
@Override
public List<String> getArgumentNames() {
return ARGUMENT_NAMES;
}
@Override
public Map<String, String> getArgumentDefaults() {
return ARGUMENT_DEFAULTS;
}
@Override
public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {
Object outputsArg = args.get(ARG_OUTPUTS);
if (outputsArg == null) {
throw new PebbleException(null, "The 'loopOutputs' function expects a non-null argument 'outputs'.", lineNumber, self.getName());
}
if (!(outputsArg instanceof List<?>)) {
throw new PebbleException(null, "The 'loopOutputs' function expects 'outputs' to be a list.", lineNumber, self.getName());
}
Object nameArg = args.get(ARG_NAME);
if (nameArg == null) {
throw new PebbleException(null, "The 'loopOutputs' function expects a non-null argument 'name'.", lineNumber, self.getName());
}
if (!(nameArg instanceof String)) {
throw new PebbleException(null, "The 'loopOutputs' function expects 'name' to be a string.", lineNumber, self.getName());
}
String key = (String) nameArg;
List<?> loopOutputs = (List<?>) outputsArg;
List<Object> result = new ArrayList<>(loopOutputs.size());
for (Object loopOutputObj : loopOutputs) {
if (loopOutputObj instanceof Map<?, ?> loopOutput) {
Object iterationOutputs = loopOutput.get(ITERATION_OUTPUTS_KEY);
result.add(iterationOutputs instanceof Map<?, ?> outputs ? outputs.get(key) : null);View on GitHub (pinned to 823fada927)
Solutions
- Ensure the outputs argument points to a Loop task's outputs, which is a list: outputs.<loopTaskId>.outputs.
- If the data is a single object, restructure the logic — loopOutputs is designed for iteration lists only.
Example fix
# before (regular task output, not a list)
value: "{{ loopOutputs(outputs.myTask, 'result') }}"
# after (Loop task iteration outputs)
value: "{{ loopOutputs(outputs.myLoop.outputs, 'result') }}" Defensive patterns
Strategy: type-guard
Validate before calling
# Verify the argument is a list before calling:
{% if outputs.myLoop.outputs is iterable %}
{{ loopOutputs(outputs.myLoop.outputs, 'myOutput') }}
{% else %}
{{ throw('loopOutputs expects a list') }}
{% endif %} Type guard
# Pebble 'is iterable' test narrows list types:
{% if myVar is iterable %}...{% endif %} Prevention
- Only pass Loop task iteration outputs (which are lists) to loopOutputs.
- Do not pass regular task output maps to loopOutputs — use direct property access instead.
- Verify the upstream task type is a Loop/ForEach before referencing its outputs.
When it happens
Trigger: Passing a single task's outputs instead of a Loop's iteration list (e.g. outputs.myTask instead of outputs.myLoop.outputs). Passing a Map or a String where a List is expected. The referenced task is not a Loop task and its outputs have a different shape.
Common situations: The author confuses a regular task's output map with a Loop's iteration list. The upstream task type changed from a ForEach/Loop to a single-execution task.
Related errors
- The 'loopOutputs' function expects 'name' to be a string.
- The 'loopOutputs' function expects a non-null argument 'outp
- The 'loopOutputs' function expects a non-null argument 'name
- The 'randomIn()' function expects an argument %s of type Lon
- Unknown value element type: {}
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/59c411787c410b5b.
Report an issue: GitHub.