{"record":{"id":"90705e5dae86ca56","repo":"kestra-io/kestra","slug":"invalid-regex-0-1-90705e","errorCode":null,"errorMessage":"Invalid regex '{0}': {1}","messagePattern":"Invalid regex '(.+?)': (.+?)","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/filters/RegexMatchFilter.java","lineNumber":64,"sourceCode":"    public Object apply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) throws PebbleException {\n        if (input == null) {\n            return false;\n        }\n\n        if (args.get(ARGUMENT_REGEX) == null) {\n            throw new PebbleException(\n                null,\n                MessageFormat.format(\"The argument ''{0}'' is required.\", ARGUMENT_REGEX),\n                lineNumber,\n                self.getName()\n            );\n        }\n\n        String regex = args.get(ARGUMENT_REGEX).toString();\n        try {\n            return RegexUtils.matcher(Pattern.compile(regex), input.toString()).find();\n        } catch (PatternSyntaxException e) {\n            throw new PebbleException(e, MessageFormat.format(\"Invalid regex ''{0}'': {1}\", regex, e.getDescription()), lineNumber, self.getName());\n        } catch (RegexUtils.RegexTimeoutException e) {\n            throw new PebbleException(e, e.getMessage(), lineNumber, self.getName());\n        }\n    }\n}\n","sourceCodeStart":46,"sourceCodeEnd":70,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/filters/RegexMatchFilter.java#L46-L70","documentation":"Thrown by the 'regexMatch' Pebble filter when `Pattern.compile(regex)` fails with a `PatternSyntaxException`. The message includes the bad pattern and the JDK's description of the syntax error.","triggerScenarios":"Malformed regex (unbalanced groups, illegal quantifiers, bad escapes); most commonly a backslash escaping problem caused by Pebble's own string parsing consuming one level of backslashes.","commonSituations":"Writing `\\d` in a Pebble literal (becomes `d`); copy-pasting a regex from another language; using POSIX classes or constructs the JDK does not support.","solutions":["Double-escape in Pebble: `\\\\d`, `\\\\w`, `\\\\s`.","Validate the pattern in a Java regex playground.","Move complex patterns into a flow variable or input to reduce escaping churn."],"exampleFix":"# before\n{{ s | regexMatch(regex=\"\\d{3}\") }}\n# after\n{{ s | regexMatch(regex=\"\\\\d{3}\") }}","handlingStrategy":"validation","validationCode":"# Double-escape backslashes in Pebble literals:\n{{ s | regexMatch(regex=\"\\\\d{3}\") }}\n# Validate in a script task first:\n# Pattern.compile(userPattern);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Double-escape metacharacters in Pebble strings.","Test the pattern in a Java regex playground before use.","Avoid unsupported constructs (some lookbehinds/possessive forms differ by JDK)."],"tags":["pebble-filter","regex-match","invalid-regex","pattern-syntax","escaping"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}