{"record":{"id":"fac560d3dcafb032","repo":"kestra-io/kestra","slug":"the-s-filter-expects-an-integer-as-argument-am","errorCode":null,"errorMessage":"The '%s' filter expects an integer as argument 'amount'.","messagePattern":"The '(.+?)' filter expects an integer as argument 'amount'\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/AbstractIndent.java","lineNumber":51,"sourceCode":"        if (input.contains(\"\\n\"))\n            return \"\\n\"; // LF\n\n        if (input.contains(\"\\r\"))\n            return \"\\r\"; // CR\n\n        return System.lineSeparator(); // System default\n    }\n\n    protected Object abstractApply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber, String indentType) throws PebbleException {\n        if (input == null) {\n            return null;\n        }\n        if (input.toString().isEmpty()) {\n            return input.toString();\n        }\n\n        if (!args.containsKey(\"amount\")) {\n            throw new PebbleException(null, String.format(\"The '%s' filter expects an integer as argument 'amount'.\", indentType), lineNumber, self.getName());\n        }\n\n        int amount = ((Long) args.get(\"amount\")).intValue();\n        if (!(amount >= 0)) {\n            throw new PebbleException(null, String.format(\"The '%s' filter expects a positive integer >=0 as argument 'amount'.\", indentType), lineNumber, self.getName());\n        }\n\n        String prefix = prefix(args);\n        String newLine = getLineSeparator(input.toString());\n\n        if (indentType.equals(\"indent\"))\n            // indent filter adds N amount of spaces to each line except for the first one (assuming the first line is already indented in place)\n            return input.toString().replace(newLine, newLine + prefix.repeat(amount));\n        else if (indentType.equals(\"nindent\")) {\n            // nindent filter adds a newline to the string and indents each line by defined amount of spaces\n            return (newLine + input).replace(newLine, newLine + prefix.repeat(amount));\n        }\n        throw new PebbleException(null, String.format(\"Unknown indent type '%s'.\", indentType), lineNumber, self.getName());","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/AbstractIndent.java#L33-L69","documentation":"Thrown by the AbstractIndent base class (used by the 'indent' and 'nindent' Pebble filters) when the required 'amount' argument is not provided in the filter call. The filter needs this integer to know how many space characters (or custom prefix) to insert per line.","triggerScenarios":"Calling the indent or nindent filter without passing the amount parameter: '{{ text | indent }}' or '{{ text | nindent }}'. Also triggered if only the optional 'prefix' argument is supplied without 'amount': '{{ text | indent(prefix=\"\\t\") }}'.","commonSituations":"Generating YAML or configuration files inside a Pebble template where indentation is needed, but the developer forgot the mandatory amount. Copy-pasting from a Helm template (which has the same filter names) without carrying over the numeric argument.","solutions":["Add the mandatory 'amount' integer argument: '{{ text | indent(4) }}'.","If using a custom prefix, still supply amount first: '{{ text | indent(4, prefix=\"\\t\") }}'.","Check that the amount is not supplied as a string literal that evaluates to null — use a bare integer."],"exampleFix":"{# before #}\n{{ block.content | indent }}\n\n{# after #}\n{{ block.content | indent(4) }}","handlingStrategy":"validation","validationCode":"{# In the Pebble template, always pass the amount argument explicitly #}\n{# Validate: ensure amount is present and is a positive integer #}\n{% set indent_amount = vars.indent_amount ?? 4 %}\n{% if indent_amount is numeric and indent_amount >= 0 %}\n  {{ text | indent(indent_amount) }}\n{% else %}\n  {{ text }}\n{% endif %}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the amount as the first positional argument to indent and nindent.","Keep a snippet library of correct filter invocations to copy from.","Run flow validation (dry-run) before deploying templates that use indentation filters."],"tags":["pebble","indent-filter","nindent-filter","missing-argument"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}