kestra-io/kestra · error · PebbleException

'chunk' filter expects an argument 'size'.

Error message

'chunk' filter expects an argument 'size'.

What it means

Thrown by the ChunkFilter Pebble filter when the required 'size' argument is not provided. The chunk filter splits a list into sub-lists of the given maximum size, so the size is mandatory.

Source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/filters/ChunkFilter.java:27

import io.pebbletemplates.pebble.extension.Filter;
import io.pebbletemplates.pebble.template.EvaluationContext;
import io.pebbletemplates.pebble.template.PebbleTemplate;

public class ChunkFilter implements Filter {
    @Override
    public List<String> getArgumentNames() {
        return List.of("size");
    }

    @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

  1. Provide the mandatory size argument: '{{ mylist | chunk(10) }}'.
  2. Ensure the size is a valid integer, not a null-valued variable.

Example fix

{# before #}
{{ mylist | chunk }}

{# after #}
{{ mylist | chunk(10) }}
Defensive patterns

Strategy: validation

Validate before calling

{# Always pass the size argument when using chunk #}
{% set batch_size = vars.batch_size ?? 10 %}
{{ mylist | chunk(batch_size) }}

Prevention

When it happens

Trigger: Calling the chunk filter without the size argument: '{{ mylist | chunk }}'. Pebble passes only named arguments that are present, so omitting size entirely leaves it out of the args map.

Common situations: Batching a list for parallel processing in a flow and forgetting the batch size. Copying a chunk filter call from documentation that showed the argument positionally but omitting it.

Related errors


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