{"record":{"id":"71057d4a0f4d497e","repo":"kestra-io/kestra","slug":"chunk-filter-argument-size-must-be-a-number-a","errorCode":null,"errorMessage":"'chunk' filter argument 'size' must be a number. Actual type was: {}","messagePattern":"'chunk' filter argument 'size' must be a number\\. Actual type was: (.+?)","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/filters/ChunkFilter.java","lineNumber":36,"sourceCode":"\n    @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n    @Override\n    public Object apply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) throws PebbleException {\n        if (input == null) {\n            return null;\n        }\n\n        if (!args.containsKey(\"size\")) {\n            throw new PebbleException(null, \"'chunk' filter expects an argument 'size'.\", lineNumber, self.getName());\n        }\n\n        if (!(input instanceof List)) {\n            throw new PebbleException(null, \"'chunk' filter can only be applied to List. Actual type was: \" + input.getClass().getName(), lineNumber, self.getName());\n        }\n\n        Object sizeObj = args.get(\"size\");\n        if (!(sizeObj instanceof Number)) {\n            throw new PebbleException(null, \"'chunk' filter argument 'size' must be a number. Actual type was: \" + sizeObj.getClass().getName(), lineNumber, self.getName());\n        }\n        return Lists.partition((List) input, ((Number) sizeObj).intValue());\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":41,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/filters/ChunkFilter.java#L18-L41","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"{# before #}\n{{ mylist | chunk(vars.batch_size) }}\n{# vars.batch_size is a string \"5\" #}\n\n{# after #}\n{{ mylist | chunk(vars.batch_size | number) }}","handlingStrategy":"validation","validationCode":"{# Ensure the size is numeric before passing to chunk #}\n{% set sz = vars.batch_size ?? 10 %}\n{% if sz is numeric %}\n  {{ mylist | chunk(sz) }}\n{% else %}\n  {{ mylist | chunk(10) }}\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["pebble","chunk-filter","invalid-argument","type-mismatch"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}