kestra-io/kestra · error · PebbleException
The 'loopOutputs' function expects 'name' to be a string.
Error message
The 'loopOutputs' function expects 'name' to be a string.
What it means
The loopOutputs() function checks that the 'name' argument is an instance of String. If name is non-null but is a number, boolean, or object, this type-check error fires. The name is used as a Map key to look up the output field in each iteration's outputs map, so it must be a string.
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/functions/LoopOutputsFunction.java:50
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);
} else {
result.add(null);
}
}
return result;
}
}View on GitHub (pinned to 823fada927)
Solutions
- Pass name as a quoted string literal or a string-typed variable: {{ loopOutputs(outputs.myLoop.outputs, 'result') }}.
- If the name comes from a variable, ensure it is a string (quote it or convert it).
Example fix
# before
value: "{{ loopOutputs(outputs.myLoop.outputs, 42) }}"
# after
value: "{{ loopOutputs(outputs.myLoop.outputs, '42') }}" Defensive patterns
Strategy: type-guard
Validate before calling
# Ensure name is a string before calling:
{% set nameVal = myVar | string %}
{{ loopOutputs(outputs.myLoop.outputs, nameVal) }} Type guard
# Pebble type narrowing — check the value is a string:
{% if myVar is string %}...{% endif %} Prevention
- Always quote string literals in Pebble expressions.
- Convert numeric variables to strings before using as output key names.
- Test the expression with sample data to verify type binding.
When it happens
Trigger: Passing a numeric value as name (e.g. loopOutputs(outputs.loop, 42)). Passing a boolean or a complex object instead of a string literal or string variable.
Common situations: The author passes an unquoted value in YAML that Pebble evaluates as a Long instead of a String. A dynamic variable that holds a number is passed where a string key is expected.
Related errors
- The 'loopOutputs' function expects 'outputs' to be a list.
- 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/b3296e58bc173f6d.
Report an issue: GitHub.