{"record":{"id":"1bb775ec5b853f1f","repo":"kestra-io/kestra","slug":"the-substringbefore-filter-expects-an-argument","errorCode":null,"errorMessage":"The 'substringBefore' filter expects an argument 'separator'.","messagePattern":"The 'substringBefore' filter expects an argument 'separator'\\.","errorType":"validation","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/filters/SubstringBeforeFilter.java","lineNumber":33,"sourceCode":"    private final List<String> argumentNames = new ArrayList<>();\n\n    public SubstringBeforeFilter() {\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 'substringBefore' 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.substringBefore(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/SubstringBeforeFilter.java#L15-L47","documentation":"The 'substringBefore' filter returns the portion of a string BEFORE the first occurrence of a separator (StringUtils.substringBefore). It registers 'separator' as a required named argument and throws when apply() is called without it.","triggerScenarios":"Calling {{ path | substringBefore }} instead of {{ path | substringBefore(separator=\"/\") }}. Triggered whenever the separator named argument is absent from the args map (undefined variable, typo, or omitted).","commonSituations":"Stripping a file extension or host from a string and forgetting the separator; separator bound to an optional output that is null; copying a snippet that used a positional separator in a Pebble version that no longer binds it positionally.","solutions":["Provide the separator argument explicitly: {{ str | substringBefore(separator=\"/\") }}.","Ensure the separator source variable is defined and non-null before use.","Spell-check the argument name (it must be exactly 'separator')."],"exampleFix":"// before\n{{ outputs.url | substringBefore }}\n// after\n{{ outputs.url | substringBefore(separator=\"://\") }}","handlingStrategy":"validation","validationCode":"{{ myVar is empty ? '' : myVar | substringBefore(separator=(mySep ?? \"/\")) }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply the separator named argument.","Guard the separator with a default to avoid an absent binding.","Spell the argument name exactly as 'separator'."],"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"}