kestra-io/kestra · error · PebbleException
Invalid regex ''{0}'': {1}
Error message
Invalid regex ''{0}'': {1} What it means
Thrown by the 'regexReplace' Pebble filter when `Pattern.compile(regex)` raises a `PatternSyntaxException`. The message embeds the bad pattern and the JDK's description so you can locate the syntax fault.
Source
Thrown at core/src/main/java/io/kestra/core/runners/pebble/filters/RegexReplaceFilter.java:73
self.getName()
);
}
if (args.get(ARGUMENT_REPLACEMENT) == null) {
throw new PebbleException(
null,
MessageFormat.format("The argument ''{0}'' is required.", ARGUMENT_REPLACEMENT),
lineNumber,
self.getName()
);
}
String regex = args.get(ARGUMENT_REGEX).toString();
String replacement = args.get(ARGUMENT_REPLACEMENT).toString();
try {
return RegexUtils.matcher(Pattern.compile(regex), input.toString()).replaceAll(replacement);
} 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 metacharacters in Pebble: `\\.`, `\\d`, `\\s`.
- Test the pattern in a Java regex tester first.
- For complex patterns, store them in a variable/input to escape once.
Example fix
# before
{{ url | regexReplace(regex="\.com", replacement=".org") }}
# after
{{ url | regexReplace(regex="\\.com", replacement=".org") }} Defensive patterns
Strategy: validation
Validate before calling
# Double-escape in Pebble literals:
{{ s | regexReplace(regex="\\.", replacement="_") }}
# Validate the pattern in a script task:
# Pattern.compile(userPattern); Prevention
- Double-escape regex metacharacters inside Pebble strings.
- Test patterns in a Java regex tester.
- Centralise complex patterns in variables/inputs to escape once.
When it happens
Trigger: Unbalanced parentheses, illegal quantifiers, malformed character classes, or backslash escaping issues induced by Pebble's string parsing.
Common situations: Writing `\.` in a Pebble literal (becomes `.`); copying a regex from JS/Python without re-escaping; using unsupported constructs.
Related errors
- Invalid regex '{0}': {1}
- Invalid regex '{0}': {1}
- The argument ''{0}'' is required.
- RegexTimeoutException: e.getMessage()
- The 'escapeChar' filter expects an argument 'type'.
AI-assisted analysis of kestra-io/kestra@823fada927 (2026-08-14).
Data as JSON: /api/errors/b748b95028dd281d.
Report an issue: GitHub.