apache/druid · error · FileNotFoundException

Could not find match for pattern

Error message

Could not find match for pattern `%s` in [%s] for %s

What it means

When a uriPrefix is configured, UriCacheGenerator asks the puller for the latest version matching the configured regex pattern via getLatestVersion(). If no URI in the prefix directory matches the pattern, it throws a FileNotFoundException with this message, naming the regex, prefix URI, and namespace.

Solutions

  1. Fix the versionRegex so it matches the actual file names under the prefix (test with a regex tool).
  2. Verify files exist at the configured uriPrefix location.
  3. Correct the uriPrefix path and confirm list permissions for the storage backend.

Example fix

// before
"versionRegex": "lookup_v\\d{8}\\.json"  // files are lookup_v1.json
// after
"versionRegex": "lookup_v\\d+\\.json"
Defensive patterns

Strategy: validation

Validate before calling

Pattern p = Pattern.compile(versionRegex);
boolean matches = listObjects(uriPrefix).stream().anyMatch(u -> p.matcher(u.toString()).find());
if (!matches) throw new IllegalStateException("versionRegex matches nothing under " + uriPrefix);

Try / catch

try { scheduler.schedule(uriNamespace); } catch (FileNotFoundException e) { if (e.getMessage().startsWith("Could not find match for pattern")) { /* fix regex or upload data */ } else { throw e; } }

Prevention

When it happens

Trigger: generateCache() with extractionNamespace.getUriPrefix() != null where puller.getLatestVersion(prefix, versionRegex) returns null — no file/object under the prefix matches the regex.

Common situations: Regex too restrictive (e.g. pattern expects a date format the files don't use); files not yet uploaded to the remote location; wrong path/prefix; permissions hide the objects from listing.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/3dfbac177f0fed4e. Report an issue: GitHub.

Appendix: source

Thrown at extensions-core/lookups-cached-global/src/main/java/org/apache/druid/server/lookup/namespace/UriCacheGenerator.java:108

      );
    }
    final URIDataPuller puller = (URIDataPuller) pullerRaw;
    final URI uri;
    if (doSearch) {
      final Pattern versionRegex;

      if (extractionNamespace.getFileRegex() != null) {
        versionRegex = Pattern.compile(extractionNamespace.getFileRegex());
      } else {
        versionRegex = null;
      }
      uri = pullerRaw.getLatestVersion(
          extractionNamespace.getUriPrefix(),
          versionRegex
      );

      if (uri == null) {
        throw new FileNotFoundException(
            StringUtils.format(
                "Could not find match for pattern `%s` in [%s] for %s",
                versionRegex,
                originalUri,
                extractionNamespace
            )
        );
      }
    } else {
      uri = extractionNamespace.getUri();
    }

    return RetryUtils.retry(
        () -> {
          final String version = puller.getVersion(uri);
          try {
            // Important to call equals() against version because lastVersion could be null
            if (version.equals(lastVersion)) {

View on GitHub (pinned to 9b90983fd2)