kestra-io/kestra · error · PebbleException

The 'substringAfterLast' filter expects an argument…

Error message

The 'substringAfterLast' filter expects an argument 'separator'.

What it means

The 'substringAfterLast' filter returns the substring after the LAST occurrence of a separator (StringUtils.substringAfterLast). Like its sibling filters it declares 'separator' as a required named argument and throws a PebbleException when args lacks the 'separator' key at apply() time.

Solutions

  1. Supply the separator argument: {{ fileName | substringAfterLast(separator=".") }}.
  2. Verify the separator expression is non-null, e.g. {{ x | substringAfterLast(separator=mySep ?? ".") }}.
  3. Use a literal separator rather than a dynamic one until the template works, then reintroduce the variable.

Example fix

// before
{{ outputs.file | substringAfterLast }}
// after
{{ outputs.file | substringAfterLast(separator=".") }}
Defensive patterns

Strategy: validation

Validate before calling

{{ myVar is empty ? '' : myVar | substringAfterLast(separator=(mySep ?? ".")) }}

Prevention

When it happens

Trigger: Invoking {{ fileName | substringAfterLast }} with no separator when the intent was to grab a file extension via {{ fileName | substringAfterLast(separator=".") }}. Also when the separator argument is bound to an undefined/null expression.

Common situations: Forgetting the argument on a less-common filter; assuming positional defaults exist (there are none); variable feeding the separator resolves to null through an optional output.

Related errors


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

Appendix: source

Thrown at core/src/main/java/io/kestra/core/runners/pebble/filters/SubstringAfterLastFilter.java:33

    private final List<String> argumentNames = new ArrayList<>();

    public SubstringAfterLastFilter() {
        this.argumentNames.add("separator");
    }

    @Override
    public List<String> getArgumentNames() {
        return this.argumentNames;
    }

    @Override
    public Object apply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) throws PebbleException {
        if (input == null) {
            return null;
        }

        if (!args.containsKey("separator")) {
            throw new PebbleException(
                null,
                "The 'substringAfterLast' filter expects an argument 'separator'.",
                lineNumber,
                self.getName()
            );
        }

        String separator = (String) args.get("separator");
        ;

        return StringUtils.substringAfterLast(input.toString(), separator);
    }
}

View on GitHub (pinned to 823fada927)