kestra-io/kestra · error · PebbleException

The '%s' filter expects an integer as argument 'amount'.

Error message

The '%s' filter expects an integer as argument 'amount'.

What it means

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.

Source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/AbstractIndent.java:51

        if (input.contains("\n"))
            return "\n"; // LF

        if (input.contains("\r"))
            return "\r"; // CR

        return System.lineSeparator(); // System default
    }

    protected Object abstractApply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber, String indentType) throws PebbleException {
        if (input == null) {
            return null;
        }
        if (input.toString().isEmpty()) {
            return input.toString();
        }

        if (!args.containsKey("amount")) {
            throw new PebbleException(null, String.format("The '%s' filter expects an integer as argument 'amount'.", indentType), lineNumber, self.getName());
        }

        int amount = ((Long) args.get("amount")).intValue();
        if (!(amount >= 0)) {
            throw new PebbleException(null, String.format("The '%s' filter expects a positive integer >=0 as argument 'amount'.", indentType), lineNumber, self.getName());
        }

        String prefix = prefix(args);
        String newLine = getLineSeparator(input.toString());

        if (indentType.equals("indent"))
            // indent filter adds N amount of spaces to each line except for the first one (assuming the first line is already indented in place)
            return input.toString().replace(newLine, newLine + prefix.repeat(amount));
        else if (indentType.equals("nindent")) {
            // nindent filter adds a newline to the string and indents each line by defined amount of spaces
            return (newLine + input).replace(newLine, newLine + prefix.repeat(amount));
        }
        throw new PebbleException(null, String.format("Unknown indent type '%s'.", indentType), lineNumber, self.getName());

View on GitHub (pinned to 823fada927)

Solutions

  1. Add the mandatory 'amount' integer argument: '{{ text | indent(4) }}'.
  2. If using a custom prefix, still supply amount first: '{{ text | indent(4, prefix="\t") }}'.
  3. Check that the amount is not supplied as a string literal that evaluates to null — use a bare integer.

Example fix

{# before #}
{{ block.content | indent }}

{# after #}
{{ block.content | indent(4) }}
Defensive patterns

Strategy: validation

Validate before calling

{# In the Pebble template, always pass the amount argument explicitly #}
{# Validate: ensure amount is present and is a positive integer #}
{% set indent_amount = vars.indent_amount ?? 4 %}
{% if indent_amount is numeric and indent_amount >= 0 %}
  {{ text | indent(indent_amount) }}
{% else %}
  {{ text }}
{% endif %}

Prevention

When it happens

Trigger: 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") }}'.

Common situations: 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.

Related errors


AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14). Data as JSON: /api/errors/fac560d3dcafb032. Report an issue: GitHub.