{"record":{"id":"d03580877b7fa9ae","repo":"kestra-io/kestra","slug":"input-must-be-a-list-but-received","errorCode":null,"errorMessage":"Input must be a list, but received : {}","messagePattern":"Input must be a list, but received : (.+?)","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/filters/DistinctFilter.java","lineNumber":36,"sourceCode":"\n    @Override\n    public Object apply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context,\n        int lineNumber) throws PebbleException {\n\n        if (input == null) {\n            return \"null\";\n        }\n\n        // Check if the input is a list\n        if (input instanceof List<?>) {\n            List<?> list = (List<?>) input;\n\n            // Deduplicate the list by using distinct stream operation\n            return list.stream().distinct().collect(Collectors.toList());\n        }\n\n        //if the input is not list, throwing exception with constructor\n        throw new PebbleException(\n            null,\n            \"Input must be a list, but received : \" + (input != null ? input.getClass().getName() : \"null\"),\n            lineNumber,\n            self != null ? self.getName() : \"Unknown\"\n        );\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":44,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/filters/DistinctFilter.java#L18-L44","documentation":"Thrown by the DistinctFilter when the input is not null but is not a List. The distinct filter deduplicates list elements using stream().distinct(); it cannot operate on strings, maps, numbers, or other types.","triggerScenarios":"Calling distinct on a non-list value: '{{ mystring | distinct }}', '{{ mymap | distinct }}', '{{ 42 | distinct }}'. The input variable resolves to a type other than List at runtime.","commonSituations":"A task output that is sometimes a list and sometimes a single scalar. Passing a JSON object where a JSON array was expected. Template logic that assumes an output is always a collection.","solutions":["Ensure the input is a list before calling distinct.","Wrap single values in a list if needed: '{{ [myvalue] | distinct }}'.","Add a type check or conditional before applying the filter."],"exampleFix":"{# before #}\n{{ outputs.task.value | distinct }}\n{# outputs.task.value is a string #}\n\n{# after — ensure list #}\n{{ [outputs.task.value] | distinct }}","handlingStrategy":"type-guard","validationCode":"{# Ensure the input is a list before calling distinct #}\n{% set input = outputs.task.value %}\n{% if input is iterable %}\n  {{ input | distinct }}\n{% else %}\n  {{ [input] | distinct }}\n{% endif %}","typeGuard":"{# Pebble 'is iterable' narrows to list-like types #}\n{% if myvar is iterable %}\n  {{ myvar | distinct }}\n{% endif %}","tryCatchPattern":null,"preventionTips":["Verify task outputs are lists before applying distinct.","Wrap single values in a list when needed.","Add a conditional type check before calling list-only filters."],"tags":["pebble","distinct-filter","type-mismatch","list"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}