{"record":{"id":"4fb648d410604af5","repo":"apache/hadoop","slug":"gettrashroot-on-path-path-is-not-within-a-moun","errorCode":null,"errorMessage":"getTrashRoot on path `<path>' is not within a mount point","messagePattern":"getTrashRoot on path `<path>' is not within a mount point","errorType":"exception","errorClass":"NotInMountpointException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java","lineNumber":1208,"sourceCode":"        mountTargetPath = mountTargetPath + \"/\";\n      }\n\n      Path targetFsUserHome = res.targetFileSystem.getHomeDirectory();\n      if (targetFSTrashRootPath.startsWith(mountTargetPath) &&\n          !(mountTargetPath.equals(ROOT_PATH.toString()) &&\n              !res.resolvedPath.equals(ROOT_PATH.toString()) &&\n              (targetFsUserHome != null && targetFSTrashRootPath.startsWith(\n                  targetFsUserHome.toUri().getPath())))) {\n        String relativeTrashRoot =\n            targetFSTrashRootPath.substring(mountTargetPath.length());\n        return makeQualified(new Path(res.resolvedPath, relativeTrashRoot));\n      } else {\n        // Return the trash root for the mount point.\n        return makeQualified(new Path(res.resolvedPath,\n            TRASH_PREFIX + \"/\" + ugi.getShortUserName()));\n      }\n    } catch (IOException | IllegalArgumentException e) {\n      throw new NotInMountpointException(path, \"getTrashRoot\");\n    }\n  }\n\n  /**\n   * Get all the trash roots for current user or all users.\n   *\n   * When FORCE_INSIDE_MOUNT_POINT is set to true, we also return trash roots\n   * under the root of each mount point, with their viewFS paths.\n   *\n   * @param allUsers return trash roots for all users if true.\n   * @return all Trash root directories.\n   */\n  @Override\n  public Collection<FileStatus> getTrashRoots(boolean allUsers) {\n    // A map from targetFSPath -> FileStatus.\n    // FileStatus can be from targetFS or viewFS.\n    HashMap<Path, FileStatus> trashRoots = new HashMap<>();\n    for (FileSystem fs : getChildFileSystems()) {","sourceCodeStart":1190,"sourceCodeEnd":1226,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java#L1190-L1226","documentation":"ViewFileSystem.getTrashRoot(Path) computes the trash location by resolving the path and asking the target file system for its trash root. Any IOException or IllegalArgumentException raised during resolution or trash computation is caught and converted into NotInMountpointException('getTrashRoot on path ... is not within a mount point'), meaning the path cannot be mapped to a backing file system (or the path itself is malformed).","triggerScenarios":"A delete/move that must consult the trash root for a working directory such as /user/<name> when /user is not mounted; getTrashRoot on a path outside every mount link; paths that trigger IllegalArgumentException during URI normalization (empty segments, embedded '..' escaping the mount, bad characters); target FS I/O errors while locating .Trash.","commonSituations":"Shell users running `hadoop fs -rm` after a viewfs migration where fs.viewfs.mounttable.default.homedir or the /user mount was never configured; scripts operating from '/' as cwd; mount tables that cover only /data and /tmp.","solutions":["Mount the user tree: fs.viewfs.mounttable.default.link.user=hdfs://nameservice1/user","Set fs.viewfs.mounttable.default.homedir=/user so trash lookups resolve for the login directory","Run the operation from (or on) a mounted path instead of the viewfs root","If trash is not required for the workflow, bypass it (delete with -skipTrash semantics / move to a mounted scratch dir) or catch NotInMountpointException and fail soft"],"exampleFix":"<!-- before: no /user mount, -rm triggers getTrashRoot -> NotInMountpointException -->\n<property>\n  <name>fs.viewfs.mounttable.default.link.data</name>\n  <value>hdfs://nameservice1/data</value>\n</property>\n\n<!-- after: add /user and homedir -->\n<property>\n  <name>fs.viewfs.mounttable.default.link.user</name>\n  <value>hdfs://nameservice1/user</value>\n</property>\n<property>\n  <name>fs.viewfs.mounttable.default.homedir</name>\n  <value>/user</value>\n</property>","handlingStrategy":"try-catch","validationCode":"// Verify cwd/home paths are mounted before trash-dependent operations\nPath home = fs.getHomeDirectory();\nif (!fs.exists(home.getParent())) {\n  throw new IllegalStateException(\"home mount missing: \" + home);\n}","typeGuard":null,"tryCatchPattern":"try {\n  Path trash = fs.getTrashRoot(p);\n} catch (NotInMountpointException e) {\n  // path not mounted or malformed: delete without trash or fail with guidance\n  throw new IOException(p + \" is not under a viewfs mount; mount it or bypass trash\", e);\n}","preventionTips":["Always mount /user and set fs.viewfs.mounttable.default.homedir","Avoid running shells with cwd at the viewfs root","Validate user-supplied paths (reject '..' escapes and empty segments) before viewfs operations"],"tags":["viewfs","hadoop","trash","mount-table","configuration"],"backgroundTag":"viewfs-not-in-mountpoint","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}