{"record":{"id":"5366b8d26f237176","repo":"apache/druid","slug":"cannot-specify-both-versionregex-and-fileregex-ve","errorCode":null,"errorMessage":"Cannot specify both versionRegex and fileRegex. versionRegex is deprecated","messagePattern":"Cannot specify both versionRegex and fileRegex\\. versionRegex is deprecated","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/namespace/UriExtractionNamespace.java","lineNumber":121,"sourceCode":"  {\n    this.uri = uri;\n    this.uriPrefix = uriPrefix;\n    if ((uri != null) == (uriPrefix != null)) {\n      throw new IAE(\"Either uri xor uriPrefix required\");\n    }\n    this.namespaceParseSpec = Preconditions.checkNotNull(namespaceParseSpec, \"namespaceParseSpec\");\n    if (pollPeriod == null) {\n      // Warning because if UriExtractionNamespace is being used for lookups, any updates to the database will not\n      // be picked up after the node starts. So for use casses where nodes start at different times (like streaming\n      // ingestion with peons) there can be data inconsistencies across the cluster.\n      LOG.warn(\"No pollPeriod configured for UriExtractionNamespace - entries will be loaded only once at startup\");\n      this.pollPeriod = Period.ZERO;\n    } else {\n      this.pollPeriod = pollPeriod;\n    }\n    this.fileRegex = fileRegex == null ? versionRegex : fileRegex;\n    if (fileRegex != null && versionRegex != null) {\n      throw new IAE(\"Cannot specify both versionRegex and fileRegex. versionRegex is deprecated\");\n    }\n\n    if (uri != null && this.fileRegex != null) {\n      throw new IAE(\"Cannot define both uri and fileRegex\");\n    }\n\n    if (this.fileRegex != null) {\n      try {\n        Pattern.compile(this.fileRegex);\n      }\n      catch (PatternSyntaxException ex) {\n        throw new IAE(ex, \"Could not parse `fileRegex` [%s]\", this.fileRegex);\n      }\n    }\n    this.maxHeapPercentage = maxHeapPercentage == null ? DEFAULT_MAX_HEAP_PERCENTAGE : maxHeapPercentage;\n  }\n\n  public String getFileRegex()","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/lookups-cached-global/src/main/java/org/apache/druid/query/lookup/namespace/UriExtractionNamespace.java#L103-L139","documentation":"UriExtractionNamespace has a legacy `versionRegex` option superseded by `fileRegex`. Because versionRegex is deprecated and the semantics overlap, the constructor rejects configs that specify both at once with this IAE. Note the check compares the raw arguments, so passing identical values for both still throws.","triggerScenarios":"Constructing UriExtractionNamespace (or deserializing lookup JSON) where both `versionRegex` and `fileRegex` keys are present in the config, even with the same value.","commonSituations":"Configs upgraded from older Druid versions that still carry versionRegex after someone added fileRegex; template-generated lookup JSON merging old and new fields; JSON kept for backward compatibility that now conflicts.","solutions":["Delete the deprecated `versionRegex` field and keep only `fileRegex`.","Migrate the pattern from versionRegex into fileRegex if the old field held the intended pattern.","Search lookup config JSON for leftover `versionRegex` keys across environments.","Pin a validation step (or JSON schema) that rejects versionRegex before submitting configs."],"exampleFix":"// before\n{\"uriPrefix\":\"s3://b/\", \"versionRegex\":\".*v[0-9]+\\.csv\", \"fileRegex\":\".*v[0-9]+\\.csv\"}\n// after\n{\"uriPrefix\":\"s3://b/\", \"fileRegex\":\".*v[0-9]+\\.csv\"}","handlingStrategy":"validation","validationCode":"// bash: reject deprecated key in lookup configs\ngrep -l versionRegex lookups/*.json && echo \"remove deprecated versionRegex\" && exit 1","typeGuard":null,"tryCatchPattern":"// java\ntry { mapper.readValue(json, UriExtractionNamespace.class); }\ncatch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"versionRegex\")) { /* drop versionRegex field */ }\n}","preventionTips":["Purge versionRegex from all lookup configs after upgrading.","Add a lint/schema rule banning deprecated fields.","Document fileRegex as the only supported filename filter."],"tags":["lookup","deprecated","configuration","validation"],"backgroundTag":"deprecated-api-usage","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}