{"record":{"id":"17cb52d08a2f581b","repo":"apache/hadoop","slug":"network-location-path-does-not-start-with","errorCode":null,"errorMessage":"Network Location path does not start with /: {}","messagePattern":"Network Location path does not start with /: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java","lineNumber":168,"sourceCode":"  /** Normalize a path by stripping off any trailing {@link #PATH_SEPARATOR}\n   * @param path path to normalize.\n   * @return the normalised path\n   * If <i>path</i>is null or empty {@link #ROOT} is returned\n   * @throws IllegalArgumentException if the first character of a non empty path\n   * is not {@link #PATH_SEPARATOR}\n   */\n  public static String normalize(String path) {\n    if (path == null) {\n      throw new IllegalArgumentException(\n          \"Network Location is null \");\n    }\n\n    if (path.length() == 0) {\n      return ROOT;\n    }\n\n    if (path.charAt(0) != PATH_SEPARATOR) {\n      throw new IllegalArgumentException(\n                                         \"Network Location path does not start with \"\n                                         +PATH_SEPARATOR_STR+ \": \"+path);\n    }\n\n    // Remove duplicated slashes.\n    path = SLASHES.matcher(path).replaceAll(\"/\");\n    \n    int len = path.length();\n    if (path.charAt(len-1) == PATH_SEPARATOR) {\n      return path.substring(0, len-1);\n    }\n    return path;\n  }\n  \n  /** @return this node's parent */\n  @Override\n  public Node getParent() { return parent; }\n  ","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java#L150-L186","documentation":"NodeBase.normalize(path) requires every non-empty path to start with '/'; it then collapses duplicated slashes (SLASHES matcher) and strips one trailing '/'. Relative-looking locations such as 'default-rack' or 'rack1/ng1' throw IllegalArgumentException.","triggerScenarios":"new NodeBase(name, \"default-rack\"), NodeBase.normalize(\"rack1\") in placement code, or topology scripts emitting rack names without the leading slash.","commonSituations":"Same misconfiguration family as NetworkTopology's normalizer: script output missing '/', hand-written StaticMapping values, locations copied from logs without the root slash.","solutions":["Always use absolute locations starting with '/'","Run external location strings through NodeBase.normalize() (after the null check) at ingestion","Fix the mapping data/script to emit slash-prefixed paths"],"exampleFix":"// before\nString loc = topologyScriptOutput(host); // \"rack1\"\n\n// after\nString loc = topologyScriptOutput(host);\nif (loc != null && !loc.startsWith(\"/\")) loc = \"/\" + loc;\nloc = NodeBase.normalize(loc);","handlingStrategy":"validation","validationCode":"String loc = location;\nif (loc != null && !loc.isEmpty() && loc.charAt(0) != '/') {\n  loc = \"/\" + loc;\n}\nloc = NodeBase.normalize(loc);","typeGuard":"static boolean hasLeadingSlash(String loc) {\n  return loc != null && !loc.isEmpty() && loc.charAt(0) == '/';\n}","tryCatchPattern":null,"preventionTips":["Pipe all external location strings through one normalization helper","Add a canary test that runs the real topology script output through NodeBase.normalize"],"tags":["hadoop-common","network-topology","path-validation","configuration"],"backgroundTag":"network-location-path-format","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}