apache/hadoop · error · IllegalArgumentException
Network location name contains /: {}
Error message
Network location name contains /: {} What it means
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.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java:90
* @param name this node's name (can be null, must not contain {@link #PATH_SEPARATOR})
* @param location this node's location
* @param parent this node's parent node
* @param level this node's level in the tree
*/
public NodeBase(String name, String location, Node parent, int level) {
set(name, normalize(location));
this.parent = parent;
this.level = level;
}
/**
* set this node's name and location
* @param name the (nullable) name -which cannot contain the {@link #PATH_SEPARATOR}
* @param location the location
*/
private void set(String name, String location) {
if (name != null && name.contains(PATH_SEPARATOR_STR))
throw new IllegalArgumentException(
"Network location name contains /: "+name);
this.name = (name==null)?"":name;
this.location = location;
}
/** @return this node's name */
@Override
public String getName() { return name; }
/** @return this node's network location */
@Override
public String getNetworkLocation() { return location; }
/** Set this node's network location
* @param location the location
*/
@Override
public void setNetworkLocation(String location) { this.location = location; }View on GitHub (pinned to 2add963021)
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
Example fix
// before
new NodeBase("/rack1/host1", "/rack1"); // name contains '/'
// after
new NodeBase("host1", "/rack1"); Defensive patterns
Strategy: validation
Validate before calling
if (name != null && name.contains("/")) {
throw new IllegalArgumentException("Node name must not contain '/': " + name);
}
Node n = new NodeBase(name, location); Type guard
static boolean isValidNodeName(String name) {
return name != null && !name.contains("/");
} Prevention
- Split full paths before constructing nodes: last segment is the name, the rest is the location
- Reject mapping entries whose host field contains '/'
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Network Locationpath doesn't start with /: {}
- Not allow to add an inner node: {}
- Not allow to remove an inner node: {}
- Network Location path does not start with /: {}
- getXAttrs on path `{}' is not within a mount point
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/b84abc5e3b12b0c2.
Report an issue: GitHub.