{"record":{"id":"6fc4188fb5c5c8a5","repo":"kestra-io/kestra","slug":"the-substringafterlast-filter-expects-an-argumen","errorCode":null,"errorMessage":"The 'substringAfterLast' filter expects an argument 'separator'.","messagePattern":"The 'substringAfterLast' filter expects an argument 'separator'\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/filters/SubstringAfterLastFilter.java","lineNumber":33,"sourceCode":"    private final List<String> argumentNames = new ArrayList<>();\n\n    public SubstringAfterLastFilter() {\n        this.argumentNames.add(\"separator\");\n    }\n\n    @Override\n    public List<String> getArgumentNames() {\n        return this.argumentNames;\n    }\n\n    @Override\n    public Object apply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) throws PebbleException {\n        if (input == null) {\n            return null;\n        }\n\n        if (!args.containsKey(\"separator\")) {\n            throw new PebbleException(\n                null,\n                \"The 'substringAfterLast' filter expects an argument 'separator'.\",\n                lineNumber,\n                self.getName()\n            );\n        }\n\n        String separator = (String) args.get(\"separator\");\n        ;\n\n        return StringUtils.substringAfterLast(input.toString(), separator);\n    }\n}\n","sourceCodeStart":15,"sourceCodeEnd":47,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/filters/SubstringAfterLastFilter.java#L15-L47","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Supply the separator argument: {{ fileName | substringAfterLast(separator=\".\") }}.","Verify the separator expression is non-null, e.g. {{ x | substringAfterLast(separator=mySep ?? \".\") }}.","Use a literal separator rather than a dynamic one until the template works, then reintroduce the variable."],"exampleFix":"// before\n{{ outputs.file | substringAfterLast }}\n// after\n{{ outputs.file | substringAfterLast(separator=\".\") }}","handlingStrategy":"validation","validationCode":"{{ myVar is empty ? '' : myVar | substringAfterLast(separator=(mySep ?? \".\")) }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass separator explicitly every time.","Confirm the separator variable is defined upstream.","Validate the expression in the editor before commit."],"tags":["pebble","template","filter","argument"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}