{"record":{"id":"fb6a64eb1aa2e2fe","repo":"apache/hadoop","slug":"no-dfs-found-in-child-fs-this-api-can-t-be-suppor","errorCode":null,"errorMessage":"No DFS found in child fs. This API can't be supported in non DFS","messagePattern":"No DFS found in child fs\\. This API can't be supported in non DFS","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ViewDistributedFileSystem.java","lineNumber":1362,"sourceCode":"\n    if (filter != null && filter.getPath() != null) {\n      ViewFileSystemOverloadScheme.MountPathInfo<FileSystem> mountPathInfo =\n          this.vfs.getMountPathInfo(filter.getPath(), getConf());\n      checkDFS(mountPathInfo.getTargetFs(), \"listCacheDirectives\");\n      return ((DistributedFileSystem) mountPathInfo.getTargetFs())\n          .listCacheDirectives(new CacheDirectiveInfo.Builder(filter)\n              .setPath(mountPathInfo.getPathOnTarget()).build());\n    }\n\n    // No path available in filter. Let's try to shoot to all child fs.\n    final List<RemoteIterator<CacheDirectiveEntry>> iters = new ArrayList<>();\n    for (FileSystem fs : getChildFileSystems()) {\n      if (fs instanceof DistributedFileSystem) {\n        iters.add(((DistributedFileSystem) fs).listCacheDirectives(filter));\n      }\n    }\n    if (iters.size() == 0) {\n      throw new UnsupportedOperationException(\n          \"No DFS found in child fs. This API can't be supported in non DFS\");\n    }\n\n    return new RemoteIterator<CacheDirectiveEntry>() {\n      int currIdx = 0;\n      RemoteIterator<CacheDirectiveEntry> currIter = iters.get(currIdx++);\n\n      @Override\n      public boolean hasNext() throws IOException {\n        if (currIter.hasNext()) {\n          return true;\n        }\n        while (currIdx < iters.size()) {\n          currIter = iters.get(currIdx++);\n          if (currIter.hasNext()) {\n            return true;\n          }\n        }","sourceCodeStart":1344,"sourceCodeEnd":1380,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/ViewDistributedFileSystem.java#L1344-L1380","documentation":"ViewDistributedFileSystem.listCacheDirectives throws UnsupportedOperationException(\"No DFS found in child fs. This API can't be supported in non DFS\") only in the fallback path: when the filter has no path, it queries every child DistributedFileSystem, and if none exists the API has nothing to serve. When the filter carries a path, the call routes to that mount's DFS instead.","triggerScenarios":"Calling listCacheDirectives with a CacheDirectiveInfo filter that has no path set, on a ViewHDFS with zero DistributedFileSystem children.","commonSituations":"Generic list-all tools using an empty filter against viewfs URIs with only object-store mounts.","solutions":["Set a path in the CacheDirectiveInfo filter so the call routes to a specific mount's DFS","Or call listCacheDirectives directly on the child DistributedFileSystem","Ensure the view contains at least one HDFS mount"],"exampleFix":"// before: empty filter, fails when no HDFS child exists\nRemoteIterator<CacheDirectiveEntry> it =\n    vfs.listCacheDirectives(new CacheDirectiveInfo.Builder().build());\n\n// after: scope the filter to a path so it routes to that mount\nRemoteIterator<CacheDirectiveEntry> it = vfs.listCacheDirectives(\n    new CacheDirectiveInfo.Builder().setPath(new Path(\"/data\")).build());","handlingStrategy":"validation","validationCode":"// Prefer a path-scoped filter: it routes to a specific mount and never\n// depends on DFS children existing\nCacheDirectiveInfo scoped = new CacheDirectiveInfo.Builder(filter)\n    .setPath(new Path(\"/data\")).build();\nRemoteIterator<CacheDirectiveEntry> it = vfs.listCacheDirectives(scoped);","typeGuard":"static boolean canListUnfiltered(FileSystem fs) {\n  return fs instanceof DistributedFileSystem\n      || (fs instanceof ViewDistributedFileSystem\n          && ((ViewDistributedFileSystem) fs).getChildFileSystems().stream()\n              .anyMatch(c -> c instanceof DistributedFileSystem));\n}","tryCatchPattern":"try {\n  return vfs.listCacheDirectives(filter);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"No DFS found in child fs\")) {\n    return Collections.emptyIterator(); // no HDFS child means no directives\n  }\n  throw e;\n}","preventionTips":["Always set a path in the CacheDirectiveInfo filter when using views","Feature-check child filesystems before list-all style calls"],"tags":["hdfs","viewfs","centralized-caching","unsupported","remote-iterator"],"backgroundTag":"viewfs-unsupported-dfs-api","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}