kestra-io/kestra · error · PebbleException
The 'substringBeforeLast' filter expects an argument…
Error message
The 'substringBeforeLast' filter expects an argument 'separator'.
What it means
The 'substringBeforeLast' filter returns the substring before the LAST occurrence of a separator (StringUtils.substringBeforeLast). It declares 'separator' as a required named argument and throws a PebbleException if args does not contain it when apply() runs.
Solutions
- Add the separator argument: {{ dir | substringBeforeLast(separator="/") }}.
- Confirm the separator variable is defined and non-null.
- Test the expression in the Kestra expression editor before committing it to the flow.
Example fix
// before
{{ outputs.path | substringBeforeLast }}
// after
{{ outputs.path | substringBeforeLast(separator="/") }} Defensive patterns
Strategy: validation
Validate before calling
{{ myVar is empty ? '' : myVar | substringBeforeLast(separator=(mySep ?? "/")) }} Prevention
- Pass separator explicitly.
- Ensure the feeding variable is non-null.
- Test the filter call in the expression editor.
When it happens
Trigger: Writing {{ dir | substringBeforeLast }} when the intent was {{ dir | substringBeforeLast(separator="/") }} (e.g. to drop the last path segment). Also when the separator expression evaluates to null.
Common situations: Path manipulation where the last segment must be removed; forgetting the argument; separator variable undefined after an upstream task produced no output.
Related errors
- The 'substringAfter' filter expects an argument 'separator'.
- The 'substringAfterLast' filter expects an argument…
- The 'substringBefore' filter expects an argument…
- getErrorMessage() [abstract: subclass-defined ERROR_MESSAGE]
- The 'dayOfMonth()' function expects a 'date' argument.
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/f2b268c6b7ae4e8e.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/filters/SubstringBeforeLastFilter.java:33
private final List<String> argumentNames = new ArrayList<>();
public SubstringBeforeLastFilter() {
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 'substringBeforeLast' filter expects an argument 'separator'.",
lineNumber,
self.getName()
);
}
String separator = (String) args.get("separator");
;
return StringUtils.substringBeforeLast(input.toString(), separator);
}
}
View on GitHub (pinned to 823fada927)