{"record":{"id":"b1ca2e773de01ed5","repo":"kestra-io/kestra","slug":"the-yaml-function-expects-an-argument-yaml","errorCode":null,"errorMessage":"The 'yaml' function expects an argument 'yaml'.","messagePattern":"The 'yaml' function expects an argument 'yaml'\\.","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/functions/YamlFunction.java","lineNumber":37,"sourceCode":"    final static ObjectMapper MAPPER = new ObjectMapper(\n        new YAMLFactory()\n    ).findAndRegisterModules();\n    private static final TypeReference<Object> TYPE_REFERENCE = new TypeReference<>() {\n    };\n\n    public List<String> getArgumentNames() {\n        return List.of(\"yaml\");\n    }\n\n    @Override\n    public Map<String, String> getArgumentDefaults() {\n        return Map.of(\"yaml\", \"inputs.yamlInput\");\n    }\n\n    @Override\n    public Object execute(Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) {\n        if (!args.containsKey(\"yaml\")) {\n            throw new PebbleException(null, \"The 'yaml' function expects an argument 'yaml'.\", lineNumber, self.getName());\n        }\n\n        if (!(args.get(\"yaml\") instanceof String)) {\n            throw new PebbleException(null, \"The 'yaml' function expects an argument 'yaml' with type string.\", lineNumber, self.getName());\n        }\n\n        String yaml = (String) args.get(\"yaml\");\n\n        try {\n            return MAPPER.readValue(yaml, TYPE_REFERENCE);\n        } catch (JacksonYAMLParseException e) {\n            throw new PebbleException(null, \"Invalid yaml: \" + e.getMessage(), lineNumber, self.getName());\n        } catch (JsonMappingException e) {\n            throw new PebbleException(null, \"Invalid yaml: \" + e.getMessage(), lineNumber, self.getName());\n        } catch (JsonProcessingException e) {\n            throw new PebbleException(null, \"Invalid yaml: \" + e.getMessage(), lineNumber, self.getName());\n        }\n    }","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/functions/YamlFunction.java#L19-L55","documentation":"The Pebble `yaml()` function requires a single argument named `yaml` containing a YAML string to parse. If the argument is absent from the args map, a `PebbleException` is thrown. The default binding (`inputs.yamlInput`) exists but does not populate `args` when the function is called without the named argument.","triggerScenarios":"Calling `yaml()` with no arguments. Calling it with a wrong argument name (e.g. `yaml(content='...')`).","commonSituations":"A developer passes a variable that resolves to null or omits the argument entirely, expecting the default to kick in automatically.","solutions":["Pass the `yaml` argument explicitly: `yaml(yaml=inputs.yamlInput)` or `yaml(inputs.yamlInput)`.","Verify the argument name is exactly `yaml`.","Ensure the referenced variable (e.g. `inputs.yamlInput`) is actually defined and non-null."],"exampleFix":"# before\n{{ yaml() }}\n# after\n{{ yaml(inputs.yamlInput) }}","handlingStrategy":"validation","validationCode":"# Pebble template: always pass the yaml argument\n{{ yaml(inputs.yamlInput) }}\n{{ yaml(yaml=someVariable) }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide the named argument explicitly.","Verify the referenced variable exists and is a string before calling yaml()."],"tags":["pebble","yaml","argument-error","validation"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}