{"record":{"id":"2a91c5c842b7a632","repo":"apache/hadoop","slug":"name-which-is-located-at-networklocation-i","errorCode":null,"errorMessage":"${name}, which is located at ${networkLocation}, is not a descendant of ${path}","messagePattern":"(.+?), which is located at (.+?), is not a descendant of (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/InnerNodeImpl.java","lineNumber":132,"sourceCode":"    if (!isAncestor(n)) {\n      throw new IllegalArgumentException(\n                                         this + \"is not an ancestor of \" + n);\n    }\n    String name = n.getNetworkLocation().substring(getPath(this).length());\n    if (name.charAt(0) == PATH_SEPARATOR) {\n      name = name.substring(1);\n    }\n    int index=name.indexOf(PATH_SEPARATOR);\n    if (index != -1) {\n      name = name.substring(0, index);\n    }\n    return name;\n  }\n\n  @Override\n  public boolean add(Node n) {\n    if (!isAncestor(n)) {\n      throw new IllegalArgumentException(n.getName()\n          + \", which is located at \" + n.getNetworkLocation()\n          + \", is not a descendant of \" + getPath(this));\n    }\n    if (isParent(n)) {\n      // this node is the parent of n; add n directly\n      n.setParent(this);\n      n.setLevel(this.level+1);\n      Node prev = childrenMap.put(n.getName(), n);\n      if (prev != null) {\n        for(int i=0; i<children.size(); i++) {\n          if (children.get(i).getName().equals(n.getName())) {\n            children.set(i, n);\n            return false;\n          }\n        }\n      }\n      children.add(n);\n      numOfLeaves++;","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/InnerNodeImpl.java#L114-L150","documentation":"IllegalArgumentException from InnerNodeImpl.add(Node) when the node being added is not located under this inner node: n's network location does not begin with this node's path, so it cannot become a child. The message includes the node name, its network location, and the path it was expected to descend from. The check keeps the topology tree consistent — you can only add '/dc1/rack1/node1' to '/dc1/rack1' or its ancestors.","triggerScenarios":"Adding a DataNode whose network location is '/rackB' to an InnerNode with path '/rackA'; calling add() on a node obtained by getLeaf while the leaf's location changed; mixing relative ('rack1') and absolute ('/rack1') location strings so the prefix test fails.","commonSituations":"Topology script returning different racks for the same node over time; DataNodes re-registered with a changed network location; custom Node implementations whose getNetworkLocation() is not normalized.","solutions":["Before add(), verify isAncestor(n) or use NetworkTopology.add() which locates the correct parent instead of guessing","Normalize all network locations in the topology script: leading '/', no trailing '/', same depth everywhere","Check that getLeaf/getInner lookups use the same location format that was used at Node registration"],"exampleFix":"// before\ninnerNodeRackA.add(nodeInRackB); // nodeInRackB.getNetworkLocation()=/rackB -> IllegalArgumentException\n\n// after\nNetworkTopology clusterTopology = new NetworkTopologyImpl();\nclusterTopology.add(nodeInRackB); // routes to the correct parent automatically","handlingStrategy":"validation","validationCode":"if (!innerNode.isAncestor(n)) {\n  // do not guess the parent; let NetworkTopology locate it\n  topology.add(n);\n  return;\n}","typeGuard":null,"tryCatchPattern":"catch (IllegalArgumentException e) { /* 'not a descendant of' */ log n's location vs expected path; re-resolve parent via getInner/NetworkTopology; }","preventionTips":["Prefer NetworkTopology.add() over InnerNode.add() in application code","Normalize location strings at Node construction time","Assert isAncestor before manual tree manipulation in tests"],"tags":["network-topology","rack","inner-node","hadoop-common","validation"],"backgroundTag":"invalid-network-location","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}