kestra-io/kestra · error · PebbleException
The '%s' filter expects a positive integer >=0 as argument '
Error message
The '%s' filter expects a positive integer >=0 as argument 'amount'.
What it means
Thrown by AbstractIndent when the 'amount' argument of the indent or nindent filter is a negative number. The filter requires amount to be zero or positive because a negative repeat count for the prefix string is meaningless.
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/AbstractIndent.java:56
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
- Change the amount to zero or a positive integer: '{{ text | indent(0) }}' or '{{ text | indent(4) }}'.
- If the amount is dynamic, clamp it with a max/min expression: '{{ text | indent(max(vars.indent, 0)) }}'.
- Audit the upstream variable or expression that produces the negative value.
Example fix
{# before #}
{{ text | indent(vars.indent_level) }}
{# where vars.indent_level = -1 #}
{# after #}
{{ text | indent(max(vars.indent_level, 0)) }} Defensive patterns
Strategy: validation
Validate before calling
{# Clamp the amount to a minimum of zero before passing it #}
{% set safe_indent = max(vars.indent_amount ?? 0, 0) %}
{{ text | indent(safe_indent) }} Prevention
- Never pass a negative literal to indent or nindent.
- When the amount is dynamic, clamp with max(value, 0).
- Validate computed indent values in the upstream task before they reach the template.
When it happens
Trigger: Passing a negative integer to indent or nindent: '{{ text | indent(-2) }}'. Also possible when the amount comes from a variable or expression that evaluates to a negative value at runtime.
Common situations: A computed amount variable that underflows to negative due to subtraction or a malformed input. Hard-coding a negative value by mistake.
Related errors
- The '%s' filter expects an integer as argument 'amount'.
- Unknown indent type '%s'.
- 'chunk' filter argument 'size' must be a number. Actual type
- The 'escapeChar' filter expects the value of 'type' to be ei
- Too many rendering attempts
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/21ad64090d1d486b.
Report an issue: GitHub.