kestra-io/kestra · error · PebbleException
'chunk' filter argument 'size' must be a number. Actual type
Error message
'chunk' filter argument 'size' must be a number. Actual type was: {} What it means
Thrown by the ChunkFilter when the 'size' argument is provided but is not a Number. The filter calls intValue() on the argument, so it must be a numeric type. Passing a string, boolean, or object triggers this error.
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/filters/ChunkFilter.java:36
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Object apply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) throws PebbleException {
if (input == null) {
return null;
}
if (!args.containsKey("size")) {
throw new PebbleException(null, "'chunk' filter expects an argument 'size'.", lineNumber, self.getName());
}
if (!(input instanceof List)) {
throw new PebbleException(null, "'chunk' filter can only be applied to List. Actual type was: " + input.getClass().getName(), lineNumber, self.getName());
}
Object sizeObj = args.get("size");
if (!(sizeObj instanceof Number)) {
throw new PebbleException(null, "'chunk' filter argument 'size' must be a number. Actual type was: " + sizeObj.getClass().getName(), lineNumber, self.getName());
}
return Lists.partition((List) input, ((Number) sizeObj).intValue());
}
}
View on GitHub (pinned to 823fada927)
Solutions
- Pass a numeric literal: '{{ mylist | chunk(10) }}'.
- If the size comes from a string variable, convert it first: '{{ mylist | chunk(vars.size | int) }}' or ensure the upstream output is typed as integer.
- Validate the variable type before passing it to the filter.
Example fix
{# before #}
{{ mylist | chunk(vars.batch_size) }}
{# vars.batch_size is a string "5" #}
{# after #}
{{ mylist | chunk(vars.batch_size | number) }} Defensive patterns
Strategy: validation
Validate before calling
{# Ensure the size is numeric before passing to chunk #}
{% set sz = vars.batch_size ?? 10 %}
{% if sz is numeric %}
{{ mylist | chunk(sz) }}
{% else %}
{{ mylist | chunk(10) }}
{% endif %} Prevention
- Pass the size as a bare integer literal, not a quoted string.
- If the size comes from a string variable, convert it to a number first.
- Type task outputs as integers when they are used as filter arguments.
When it happens
Trigger: Passing a non-numeric value as the chunk size: '{{ mylist | chunk("ten") }}', '{{ mylist | chunk(true) }}'. The size comes from a variable that resolves to a non-numeric type at runtime.
Common situations: A size variable sourced from user input or an external system that arrives as a string instead of a number. Hard-coding the size as a quoted string by mistake.
Related errors
- 'chunk' filter can only be applied to List. Actual type was:
- The '%s' filter expects a positive integer >=0 as argument '
- Cannot concat {} with {}
- Could not perform greater than or equals comparison
- Could not perform greater than comparison
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/71057d4a0f4d497e.
Report an issue: GitHub.