{"record":{"id":"8540346b9f2fdcf7","repo":"apache/hadoop","slug":"cannot-find-locations-for-because-the-default","errorCode":null,"errorMessage":"Cannot find locations for {}, because the default nameservice is disabled to read or write","messagePattern":"Cannot find locations for (.+?), because the default nameservice is disabled to read or write","errorType":"exception","errorClass":"RouterResolveException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MountTableResolver.java","lineNumber":502,"sourceCode":"  }\n\n  /**\n   * Build the path location to insert into the cache atomically. It must hold\n   * the read lock.\n   * @param str Path to check/insert.\n   * @return New remote location.\n   * @throws IOException If it cannot find the location.\n   */\n  public PathLocation lookupLocation(final String str) throws IOException {\n    PathLocation ret = null;\n    final String path = RouterAdmin.normalizeFileSystemPath(str);\n    MountTable entry = findDeepest(path);\n    if (entry != null) {\n      ret = buildLocation(path, entry);\n    } else {\n      // Not found, use default location\n      if (!defaultNSEnable) {\n        throw new RouterResolveException(\"Cannot find locations for \" + path\n            + \", because the default nameservice is disabled to read or write\");\n      }\n      RemoteLocation remoteLocation =\n          new RemoteLocation(defaultNameService, path, path);\n      List<RemoteLocation> locations =\n          Collections.singletonList(remoteLocation);\n      ret = new PathLocation(null, locations);\n    }\n    return ret;\n  }\n\n  /**\n   * Get the mount table entry for a path.\n   *\n   * @param path Path to look for.\n   * @return Mount table entry the path belongs.\n   * @throws IOException If the State Store could not be reached.\n   */","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/resolver/MountTableResolver.java#L484-L520","documentation":"MountTableResolver.lookupLocation() resolves a path to its remote location by finding the deepest matching mount entry. If no entry matches, the fallback is to route the path to the default nameservice — but when that fallback is disabled (dfs.federation.router.default.nameservice.enable=false, key dfs.federation.router.default.nameserviceId for the id) it throws RouterResolveException: in strict mode only explicitly mounted paths are routable.","triggerScenarios":"A client sends a filesystem RPC through the router for a path not under any mount table entry (e.g., /user/me with no /user mount, /tmp with no mount) while the router runs with the default-nameservice fallback disabled.","commonSituations":"RBF deployments that disable default-NS fallback to enforce mount hygiene; new path trees used by clients before an admin adds the mount; applications with hardcoded absolute paths outside the mounted tree.","solutions":["Add a mount covering the path: hdfs dfsrouteradmin -add /user -ns ns0 -dst /user, then refresh the router caches","Or re-enable the fallback: set dfs.federation.router.default.nameservice.enable=true and dfs.federation.router.default.nameserviceId=<healthy nsId>, restart the router","Audit client paths against hdfs dfsrouteradmin -list and align them with mounted trees"],"exampleFix":"<!-- before: strict mode, no mount for /user -->\n<property>\n  <name>dfs.federation.router.default.nameservice.enable</name>\n  <value>false</value>\n</property>\n<!-- after: enable default-nameservice fallback -->\n<property>\n  <name>dfs.federation.router.default.nameservice.enable</name>\n  <value>true</value>\n</property>\n<property>\n  <name>dfs.federation.router.default.nameserviceId</name>\n  <value>ns0</value>\n</property>","handlingStrategy":"fallback","validationCode":"// Client-side: verify the path falls under a mount before sending traffic\nCollection<MountTable> mounts = routerClient.getMountTableManager()\n    .getMountTableEntries(null).getEntries();\nboolean covered = mounts.stream()\n    .anyMatch(m -> normalizedPath.startsWith(m.getSourcePath()));\nif (!covered && !defaultNsFallbackEnabled) {\n  // route directly to a concrete cluster instead of the router\n  target = new Path(\"hdfs://ns0\" + normalizedPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  PathLocation loc = resolver.lookupLocation(path);\n} catch (RouterResolveException e) {\n  // not mounted and default NS disabled → send the op straight to a concrete cluster\n  return new Path(\"hdfs://ns0\" + path);\n}","preventionTips":["Mount every path tree clients use before enabling strict (no-default-NS) mode","Audit client path templates against dfsrouteradmin -list","When fallback is enabled, keep dfs.federation.router.default.nameserviceId pointing at a healthy namespace"],"tags":["hadoop","rbf","router","mount-table","path-resolution","configuration"],"backgroundTag":"unresolved-route-path","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}