{"record":{"id":"cfa85843770c29df","repo":"kestra-io/kestra","slug":"regextimeoutexception-e-getmessage","errorCode":null,"errorMessage":"RegexTimeoutException: e.getMessage()","messagePattern":"RegexTimeoutException: e\\.getMessage\\(\\)","errorType":"exception","errorClass":"PebbleException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/io/kestra/core/runners/pebble/filters/RegexReplaceFilter.java","lineNumber":75,"sourceCode":"        }\n\n        if (args.get(ARGUMENT_REPLACEMENT) == null) {\n            throw new PebbleException(\n                null,\n                MessageFormat.format(\"The argument ''{0}'' is required.\", ARGUMENT_REPLACEMENT),\n                lineNumber,\n                self.getName()\n            );\n        }\n\n        String regex = args.get(ARGUMENT_REGEX).toString();\n        String replacement = args.get(ARGUMENT_REPLACEMENT).toString();\n        try {\n            return RegexUtils.matcher(Pattern.compile(regex), input.toString()).replaceAll(replacement);\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":57,"sourceCodeEnd":79,"githubUrl":"https://github.com/kestra-io/kestra/blob/823fada9274c4f9c251ea0a516460a4f7d958032/core/src/main/java/io/kestra/core/runners/pebble/filters/RegexReplaceFilter.java#L57-L79","documentation":"Thrown by the 'regexReplace' Pebble filter when the underlying `RegexUtils.matcher(...).replaceAll(replacement)` call raises a `RegexUtils.RegexTimeoutException`. Kestra wraps regex execution in a timeout guard to prevent catastrophic backtracking (ReDoS) from hanging task evaluation; exceeding it surfaces as this error.","triggerScenarios":"A regex prone to catastrophic backtracking applied to a long or adversarial input string (e.g. `(a+)+$` against a string of 'a's); a pattern with nested quantifiers and no anchoring.","commonSituations":"User-supplied input flowing into a regex without sanitization; copy-pasted regex from Stack Overflow that is not linear; large log lines being processed.","solutions":["Simplify the regex to a linear-time equivalent (avoid nested unbounded quantifiers).","Anchor the pattern and use possessive quantifiers or atomic groups where supported.","Pre-truncate or pre-filter very long input before applying the regex.","If the match is the goal, switch to `regexMatch` or `regexExtract` which may short-circuit faster than `replaceAll`."],"exampleFix":"# before - catastrophic backtracking\n{{ log | regexReplace(regex=\"(a+)+b\", replacement=\"x\") }}\n# after - linear\n{{ log | regexReplace(regex=\"a+b\", replacement=\"x\") }}","handlingStrategy":"validation","validationCode":"# Rewrite vulnerable patterns to linear equivalents and pre-truncate input:\n{% set safeInput = (log ?? \"\") | slice(0, 10000) %}\n{{ safeInput | regexReplace(regex=\"a+b\", replacement=\"x\") }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid nested unbounded quantifiers like `(a+)+`.","Pre-truncate long inputs before regex substitution.","Audit copy-pasted regexes for catastrophic backtracking (ReDoS).","Prefer anchored, linear patterns."],"tags":["pebble-filter","regex-replace","timeout","redos","performance","backtracking"],"backgroundTag":null,"analyzedSha":"823fada9274c4f9c251ea0a516460a4f7d958032","analyzedAt":"2026-08-14T06:15:17.947Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}