apache/druid · error · IllegalArgumentException
Could not parse `fileRegex
Error message
Could not parse `fileRegex` [%s]
What it means
After the mutually-exclusive checks, UriExtractionNamespace's constructor validates fileRegex by compiling it with Pattern.compile. A PatternSyntaxException is rethrown as this IAE (with the bad pattern and the cause attached), so malformed regexes fail fast at config load instead of at poll time.
Solutions
- Fix the fileRegex to be a valid Java regular expression; test it with Pattern.compile or a Java-regex validator.
- Double JSON backslashes in escape sequences (e.g. ".*\\\\.csv" in JSON for ".*\\.csv" in Java).
- Check the wrapped PatternSyntaxException message for the exact character index of the syntax error.
- Simplify the pattern or use a broader prefix match if complex filtering is unnecessary.
Example fix
// before (invalid Java regex) "fileRegex": "[a-z" // after "fileRegex": "[a-z]+\\.csv"
Defensive patterns
Strategy: validation
Validate before calling
// java
String regex = cfg.get("fileRegex").asText();
try { java.util.regex.Pattern.compile(regex); }
catch (java.util.regex.PatternSyntaxException e) {
throw new IllegalArgumentException("bad fileRegex: " + e.getMessage());
} Try / catch
// java
try { mapper.readValue(json, UriExtractionNamespace.class); }
catch (IllegalArgumentException e) {
if (e.getMessage().contains("Could not parse `fileRegex`")) { /* fix pattern */ }
} Prevention
- Compile the pattern with Pattern.compile in a unit test before shipping configs.
- Remember JSON string escaping: double backslashes for regex escapes.
- Use Java-flavored regex syntax, not grep/PCRE extensions.
When it happens
Trigger: Providing a syntactically invalid fileRegex (e.g. "[a-", "*foo", unbalanced parentheses, bad escape like "\\\\" errors) in the UriExtractionNamespace config.
Common situations: Regexes written for grep/sed syntax rather than Java regex; unescaped dots/brackets in filename patterns; string-escaping mistakes in JSON where backslashes were consumed by the JSON parser, leaving an invalid Java pattern.
Related errors
- Cannot define both uri and fileRegex
- Cannot specify both versionRegex and fileRegex…
- Either uri xor uriPrefix required
- At least one task runner must be enabled
- Cannot have fault tolerance without durable storage
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/09baaa8c8ff42f80.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/namespace/UriExtractionNamespace.java:133
this.pollPeriod = Period.ZERO;
} else {
this.pollPeriod = pollPeriod;
}
this.fileRegex = fileRegex == null ? versionRegex : fileRegex;
if (fileRegex != null && versionRegex != null) {
throw new IAE("Cannot specify both versionRegex and fileRegex. versionRegex is deprecated");
}
if (uri != null && this.fileRegex != null) {
throw new IAE("Cannot define both uri and fileRegex");
}
if (this.fileRegex != null) {
try {
Pattern.compile(this.fileRegex);
}
catch (PatternSyntaxException ex) {
throw new IAE(ex, "Could not parse `fileRegex` [%s]", this.fileRegex);
}
}
this.maxHeapPercentage = maxHeapPercentage == null ? DEFAULT_MAX_HEAP_PERCENTAGE : maxHeapPercentage;
}
public String getFileRegex()
{
return fileRegex;
}
public FlatDataParser getNamespaceParseSpec()
{
return this.namespaceParseSpec;
}
public URI getUri()
{
return uri;View on GitHub (pinned to 9b90983fd2)