{"record":{"id":"5f37501b10b08c0a","repo":"kestra-io/kestra","slug":"the-loopoutputs-function-expects-a-non-null-argu","errorCode":null,"errorMessage":"The 'loopOutputs' function expects a non-null argument 'outputs'.","messagePattern":"The 'loopOutputs' function expects a non-null argument 'outputs'\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/LoopOutputsFunction.java","lineNumber":39,"sourceCode":"        ARG_OUTPUTS, \"outputs.myLoop.outputs\",\n        ARG_NAME, \"'myOutputName'\"\n    );\n\n    @Override\n    public List<String> getArgumentNames() {\n        return ARGUMENT_NAMES;\n    }\n\n    @Override\n    public Map<String, String> getArgumentDefaults() {\n        return ARGUMENT_DEFAULTS;\n    }\n\n    @Override\n    public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {\n        Object outputsArg = args.get(ARG_OUTPUTS);\n        if (outputsArg == null) {\n            throw new PebbleException(null, \"The 'loopOutputs' function expects a non-null argument 'outputs'.\", lineNumber, self.getName());\n        }\n        if (!(outputsArg instanceof List<?>)) {\n            throw new PebbleException(null, \"The 'loopOutputs' function expects 'outputs' to be a list.\", lineNumber, self.getName());\n        }\n\n        Object nameArg = args.get(ARG_NAME);\n        if (nameArg == null) {\n            throw new PebbleException(null, \"The 'loopOutputs' function expects a non-null argument 'name'.\", lineNumber, self.getName());\n        }\n        if (!(nameArg instanceof String)) {\n            throw new PebbleException(null, \"The 'loopOutputs' function expects 'name' to be a string.\", lineNumber, self.getName());\n        }\n\n        String key = (String) nameArg;\n        List<?> loopOutputs = (List<?>) outputsArg;\n        List<Object> result = new ArrayList<>(loopOutputs.size());\n\n        for (Object loopOutputObj : loopOutputs) {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/LoopOutputsFunction.java#L21-L57","documentation":"The loopOutputs(outputs, name) Pebble function requires a non-null 'outputs' argument. This argument should be a reference to a Loop task's iteration list (e.g. outputs.myLoop.outputs). If the argument is absent or resolves to null, the function cannot iterate and throws immediately.","triggerScenarios":"Calling {{ loopOutputs() }} with no arguments. Calling {{ loopOutputs(name='myOutput') }} without the outputs argument. Referencing a loop task ID that does not exist or whose outputs are null (e.g. the loop task has not executed yet).","commonSituations":"The flow author misspells the loop task ID in the outputs reference. The loop task has no iterations (empty for-each), so its outputs are null. The function is called outside the context of a Loop task.","solutions":["Provide a valid outputs reference from a Loop task: {{ loopOutputs(outputs.myLoop.outputs, 'myOutput') }}.","Verify the Loop task ID matches the reference exactly.","If the loop may have zero iterations, guard with a null check: {% if outputs.myLoop.outputs is not null %}{{ loopOutputs(outputs.myLoop.outputs, 'myOutput') }}{% endif %}."],"exampleFix":"# before\nvalue: \"{{ loopOutputs(name='result') }}\"\n# after\nvalue: \"{{ loopOutputs(outputs.myLoop.outputs, 'result') }}\"","handlingStrategy":"validation","validationCode":"# Guard against null outputs before calling loopOutputs:\n{% if outputs.myLoop.outputs is not null %}\n  {{ loopOutputs(outputs.myLoop.outputs, 'myOutput') }}\n{% else %}\n  []\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass a valid Loop task outputs reference as the first argument.","Verify the Loop task ID matches exactly.","Guard against null when the loop may have zero iterations."],"tags":["pebble-function","loopoutputs","missing-argument"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}