kestra-io/kestra · error · PebbleException
Invalid regex '{0}': {1}
Error message
Invalid regex '{0}': {1} What it means
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.
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/filters/RegexMatchFilter.java:64
public Object apply(Object input, Map<String, Object> args, PebbleTemplate self, EvaluationContext context, int lineNumber) throws PebbleException {
if (input == null) {
return false;
}
if (args.get(ARGUMENT_REGEX) == null) {
throw new PebbleException(
null,
MessageFormat.format("The argument ''{0}'' is required.", ARGUMENT_REGEX),
lineNumber,
self.getName()
);
}
String regex = args.get(ARGUMENT_REGEX).toString();
try {
return RegexUtils.matcher(Pattern.compile(regex), input.toString()).find();
} catch (PatternSyntaxException e) {
throw new PebbleException(e, MessageFormat.format("Invalid regex ''{0}'': {1}", regex, e.getDescription()), lineNumber, self.getName());
} catch (RegexUtils.RegexTimeoutException e) {
throw new PebbleException(e, e.getMessage(), lineNumber, self.getName());
}
}
}
View on GitHub (pinned to 823fada927)
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.
Example fix
# before
{{ s | regexMatch(regex="\d{3}") }}
# after
{{ s | regexMatch(regex="\\d{3}") }} Defensive patterns
Strategy: validation
Validate before calling
# Double-escape backslashes in Pebble literals:
{{ s | regexMatch(regex="\\d{3}") }}
# Validate in a script task first:
# Pattern.compile(userPattern); Prevention
- 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).
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid regex '{0}': {1}
- Invalid regex ''{0}'': {1}
- The argument 'regex' is required.
- The 'escapeChar' filter expects an argument 'type'.
- The 'escapeChar' filter expects the value of 'type' to be ei
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/90705e5dae86ca56.
Report an issue: GitHub.