{"record":{"id":"b84abc5e3b12b0c2","repo":"apache/hadoop","slug":"network-location-name-contains","errorCode":null,"errorMessage":"Network location name contains /: {}","messagePattern":"Network location name contains /: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java","lineNumber":90,"sourceCode":"   * @param name this node's name (can be null, must not contain {@link #PATH_SEPARATOR})\n   * @param location this node's location \n   * @param parent this node's parent node\n   * @param level this node's level in the tree\n   */\n  public NodeBase(String name, String location, Node parent, int level) {\n    set(name, normalize(location));\n    this.parent = parent;\n    this.level = level;\n  }\n\n  /**\n   * set this node's name and location\n   * @param name the (nullable) name -which cannot contain the {@link #PATH_SEPARATOR}\n   * @param location the location\n   */\n  private void set(String name, String location) {\n    if (name != null && name.contains(PATH_SEPARATOR_STR))\n      throw new IllegalArgumentException(\n                                         \"Network location name contains /: \"+name);\n    this.name = (name==null)?\"\":name;\n    this.location = location;      \n  }\n  \n  /** @return this node's name */\n  @Override\n  public String getName() { return name; }\n  \n  /** @return this node's network location */\n  @Override\n  public String getNetworkLocation() { return location; }\n  \n  /** Set this node's network location\n   * @param location the location\n   */\n  @Override\n  public void setNetworkLocation(String location) { this.location = location; }","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java#L72-L108","documentation":"NodeBase.set(name, location) validates that a node's NAME contains no '/' (PATH_SEPARATOR_STR). The name identifies the leaf itself (typically host:port); all hierarchy lives in the location string. A slash inside the name would corrupt path parsing, so IllegalArgumentException is thrown at construction.","triggerScenarios":"new NodeBase(\"host/rack\", \"/rack\") or any set(...) call where the name embeds a '/'. Common: feeding a full path '/rack/host' back in as the name when reconstructing nodes.","commonSituations":"Round-tripping NodeBase.getPath(node) output and passing it as the name to a new NodeBase; test fixtures that conflate name and location; parsing datanode names that contain escaped slashes.","solutions":["Keep the name slash-free: pass only the host identifier or host:port","When recreating a node from a path, split it: name = last component, location = the remaining prefix","Validate with name.contains(\"/\") before constructing"],"exampleFix":"// before\nnew NodeBase(\"/rack1/host1\", \"/rack1\"); // name contains '/'\n\n// after\nnew NodeBase(\"host1\", \"/rack1\");","handlingStrategy":"validation","validationCode":"if (name != null && name.contains(\"/\")) {\n  throw new IllegalArgumentException(\"Node name must not contain '/': \" + name);\n}\nNode n = new NodeBase(name, location);","typeGuard":"static boolean isValidNodeName(String name) {\n  return name != null && !name.contains(\"/\");\n}","tryCatchPattern":null,"preventionTips":["Split full paths before constructing nodes: last segment is the name, the rest is the location","Reject mapping entries whose host field contains '/'"],"tags":["hadoop-common","network-topology","path-validation","java"],"backgroundTag":"node-name-contains-separator","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}