{"record":{"id":"ea0729dcfc5b0cb8","repo":"apache/hadoop","slug":"getstoragepolicy-on-path-is-not-within-a-moun","errorCode":null,"errorMessage":"getStoragePolicy on path `{}' is not within a mount point","messagePattern":"getStoragePolicy on 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":1912,"sourceCode":"      throw readOnlyMountTable(\"satisfyStoragePolicy\", src);\n    }\n\n    @Override\n    public void setStoragePolicy(Path src, String policyName)\n        throws IOException {\n      checkPathIsSlash(src);\n      throw readOnlyMountTable(\"setStoragePolicy\", src);\n    }\n\n    @Override\n    public void unsetStoragePolicy(Path src) throws IOException {\n      checkPathIsSlash(src);\n      throw readOnlyMountTable(\"unsetStoragePolicy\", src);\n    }\n\n    @Override\n    public BlockStoragePolicySpi getStoragePolicy(Path src) throws IOException {\n      throw new NotInMountpointException(src, \"getStoragePolicy\");\n    }\n\n    @Override\n    public Collection<? extends BlockStoragePolicySpi> getAllStoragePolicies()\n        throws IOException {\n      Collection<BlockStoragePolicySpi> allPolicies = new HashSet<>();\n      for (FileSystem fs : getChildFileSystems()) {\n        try {\n          Collection<? extends BlockStoragePolicySpi> policies =\n              fs.getAllStoragePolicies();\n          allPolicies.addAll(policies);\n        } catch (UnsupportedOperationException e) {\n          // ignored\n        }\n      }\n      return allPolicies;\n    }\n","sourceCodeStart":1894,"sourceCodeEnd":1930,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java#L1894-L1930","documentation":"ViewFileSystem.getStoragePolicy throws NotInMountpointException from InternalDirOfViewFs when the path resolves to an internal (virtual) mount-table directory. Storage policies are a property of the backing HDFS cluster, so the overlay cannot answer for a node with no child FileSystem. The exception is unchecked.","triggerScenarios":"`hdfs storagepolicies -getStoragePolicy -path viewfs:///...` where the path is / or an unmounted ancestor; fs.getStoragePolicy(new Path(\"/\")) on a viewfs FileSystem; storage-policy audit scripts walking a federated namespace.","commonSituations":"Operators running storage-policy tooling after switching the defaultFS to viewfs:// (federation); scripts written against plain HDFS URIs reused unchanged on viewfs; mount tables that only mount leaf dirs.","solutions":["Run getStoragePolicy on a concrete mounted path (e.g. viewfs:///data/ds1/file)","Add a mount link for the prefix, or configure linkMergeSlash/linkFallback for root coverage","Catch NotInMountpointException and surface 'no policy: not a mounted path' to the CLI user"],"exampleFix":"// before\nBlockStoragePolicySpi pol = vfs.getStoragePolicy(new Path(\"/\"));\n\n// after\nBlockStoragePolicySpi pol;\ntry {\n  pol = vfs.getStoragePolicy(p);\n} catch (NotInMountpointException e) {\n  pol = null; // virtual dir: policy lives on the backing cluster\n}","handlingStrategy":"try-catch","validationCode":"static boolean storagePolicyQueryable(ViewFileSystem vfs, Path p) {\n  String s = p.toUri().getPath();\n  return vfs.getMountPoints().stream()\n      .map(mp -> mp.getMountedOnPath().toUri().getPath())\n      .anyMatch(m -> s.equals(m) || s.startsWith(m + \"/\"));\n}","typeGuard":null,"tryCatchPattern":"try {\n  policy = vfs.getStoragePolicy(p);\n} catch (NotInMountpointException e) {\n  policy = null; // ask the backing HDFS cluster directly instead\n}","preventionTips":["Run storage-policy commands with the concrete hdfs:// cluster URI, not viewfs:// parents","CLI wrappers should verify the path is inside a mount point before calling policy APIs"],"tags":["viewfs","mount-table","storage-policy","hadoop-common","java"],"backgroundTag":"viewfs-not-in-mountpoint","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}