{"record":{"id":"b3296e58bc173f6d","repo":"kestra-io/kestra","slug":"the-loopoutputs-function-expects-name-to-be-a","errorCode":null,"errorMessage":"The 'loopOutputs' function expects 'name' to be a string.","messagePattern":"The 'loopOutputs' function expects 'name' to be a string\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/LoopOutputsFunction.java","lineNumber":50,"sourceCode":"        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) {\n            if (loopOutputObj instanceof Map<?, ?> loopOutput) {\n                Object iterationOutputs = loopOutput.get(ITERATION_OUTPUTS_KEY);\n                result.add(iterationOutputs instanceof Map<?, ?> outputs ? outputs.get(key) : null);\n            } else {\n                result.add(null);\n            }\n        }\n\n        return result;\n    }\n}","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/LoopOutputsFunction.java#L32-L68","documentation":"The loopOutputs() function checks that the 'name' argument is an instance of String. If name is non-null but is a number, boolean, or object, this type-check error fires. The name is used as a Map key to look up the output field in each iteration's outputs map, so it must be a string.","triggerScenarios":"Passing a numeric value as name (e.g. loopOutputs(outputs.loop, 42)). Passing a boolean or a complex object instead of a string literal or string variable.","commonSituations":"The author passes an unquoted value in YAML that Pebble evaluates as a Long instead of a String. A dynamic variable that holds a number is passed where a string key is expected.","solutions":["Pass name as a quoted string literal or a string-typed variable: {{ loopOutputs(outputs.myLoop.outputs, 'result') }}.","If the name comes from a variable, ensure it is a string (quote it or convert it)."],"exampleFix":"# before\nvalue: \"{{ loopOutputs(outputs.myLoop.outputs, 42) }}\"\n# after\nvalue: \"{{ loopOutputs(outputs.myLoop.outputs, '42') }}\"","handlingStrategy":"type-guard","validationCode":"# Ensure name is a string before calling:\n{% set nameVal = myVar | string %}\n{{ loopOutputs(outputs.myLoop.outputs, nameVal) }}","typeGuard":"# Pebble type narrowing — check the value is a string:\n{% if myVar is string %}...{% endif %}","tryCatchPattern":null,"preventionTips":["Always quote string literals in Pebble expressions.","Convert numeric variables to strings before using as output key names.","Test the expression with sample data to verify type binding."],"tags":["pebble-function","loopoutputs","type-mismatch"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}