{"record":{"id":"87f98bbcc03375c6","repo":"apache/hadoop","slug":"filesystem-is-not-a-viewfilesystem","errorCode":null,"errorMessage":"FileSystem '{}'is not a ViewFileSystem.","messagePattern":"FileSystem '(.+?)'is not a ViewFileSystem\\.","errorType":"exception","errorClass":"UnsupportedFileSystemException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystemUtil.java","lineNumber":110,"sourceCode":"   *\n   *  \"/dept/eng\"           Not a mount point, but a valid   (1), (2), (3), (4)\n   *                         internal dir in the mount tree\n   *                         and resolved down to \"/\" path.\n   *\n   *  \"/erp\"                Doesn't match or leads to or\n   *                         over any valid mount points     None\n   *\n   *\n   * @param fileSystem - ViewFileSystem on which mount point exists\n   * @param path - URI for which FsStatus is requested\n   * @return Map of ViewFsMountPoint and FsStatus\n   * @throws IOException raised on errors performing I/O.\n   */\n  public static Map<MountPoint, FsStatus> getStatus(\n      FileSystem fileSystem, Path path) throws IOException {\n    if (!(isViewFileSystem(fileSystem)\n        || isViewFileSystemOverloadScheme(fileSystem))) {\n      throw new UnsupportedFileSystemException(\"FileSystem '\"\n          + fileSystem.getUri() + \"'is not a ViewFileSystem.\");\n    }\n    ViewFileSystem viewFileSystem = (ViewFileSystem) fileSystem;\n    String viewFsUriPath = viewFileSystem.getUriPath(path);\n    boolean isPathOverMountPoint = false;\n    boolean isPathLeadingToMountPoint = false;\n    boolean isPathIncludesAllMountPoint = false;\n    Map<MountPoint, FsStatus> mountPointMap = new HashMap<>();\n    for (MountPoint mountPoint : viewFileSystem.getMountPoints()) {\n      String[] mountPointPathComponents = InodeTree.breakIntoPathComponents(\n          mountPoint.getMountedOnPath().toString());\n      String[] incomingPathComponents =\n          InodeTree.breakIntoPathComponents(viewFsUriPath);\n\n      int pathCompIndex;\n      for (pathCompIndex = 0; pathCompIndex < mountPointPathComponents.length &&\n          pathCompIndex < incomingPathComponents.length; pathCompIndex++) {\n        if (!mountPointPathComponents[pathCompIndex].equals(","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystemUtil.java#L92-L128","documentation":"ViewFileSystemUtil.getStatus(FileSystem, Path) computes per-mount-point FsStatus but only accepts ViewFileSystem or ViewFileSystemOverloadScheme instances. Any other FileSystem (plain DistributedFileSystem, RawLocalFileSystem, S3A, HarFs, ...) fails fast with UnsupportedFileSystemException(\"FileSystem '<uri>'is not a ViewFileSystem.\") before any status is read.","triggerScenarios":"Calling ViewFileSystemUtil.getStatus(FileSystem.get(conf), path) when the Configuration resolves to a non-viewfs scheme; helper code shared between unit tests (local FS) and production (viewfs) passing whatever FileSystem it was handed.","commonSituations":"Cluster-capacity UIs and ops tooling that assume the defaultFS is always viewfs:// (federation) but are run on a single-cluster gateway where defaultFS=hdfs://; test harnesses using LocalFileSystem through the same code path.","solutions":["Guard the call with ViewFileSystemUtil.isViewFileSystem(fs) || ViewFileSystemUtil.isViewFileSystemOverloadScheme(fs) and branch to fs.getStatus() otherwise","Construct the viewfs FileSystem explicitly: FileSystem.get(new URI(\"viewfs://cluster\"), conf)","Ensure the tool is pointed at a deployment whose defaultFS is the viewfs mount table"],"exampleFix":"// before\nMap<MountPoint, FsStatus> m = ViewFileSystemUtil.getStatus(fs, path); // throws for hdfs://\n\n// after\nif (ViewFileSystemUtil.isViewFileSystem(fs)\n    || ViewFileSystemUtil.isViewFileSystemOverloadScheme(fs)) {\n  Map<MountPoint, FsStatus> m = ViewFileSystemUtil.getStatus(fs, path);\n} else {\n  FsStatus s = fs.getStatus(path); // single-FS fallback path\n}","handlingStrategy":"type-guard","validationCode":"if (!ViewFileSystemUtil.isViewFileSystem(fs)\n    && !ViewFileSystemUtil.isViewFileSystemOverloadScheme(fs)) {\n  FsStatus s = fs.getStatus(path); // single-FS path\n} else {\n  Map<MountPoint, FsStatus> m = ViewFileSystemUtil.getStatus(fs, path);\n}","typeGuard":"static boolean isViewFsCapable(FileSystem fs) {\n  // ViewFileSystemOverloadScheme extends ViewFileSystem, so one check covers both\n  return fs instanceof org.apache.hadoop.fs.viewfs.ViewFileSystem;\n}","tryCatchPattern":"try {\n  statuses = ViewFileSystemUtil.getStatus(fs, path);\n} catch (UnsupportedFileSystemException e) {\n  statuses = Map.of(); // fall back to fs.getStatus(path) for plain filesystems\n}","preventionTips":["Do not hardcode ViewFileSystemUtil calls for user-supplied FileSystem instances","Test such utils with LocalFileSystem AND a viewfs test harness (ViewFileSystemTestSetup)"],"tags":["viewfs","type-mismatch","fs-status","hadoop-common","java"],"backgroundTag":"unsupported-filesystem-type","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}