{"record":{"id":"fbbd822901079b8a","repo":"apache/hadoop","slug":"invalid-value-in-server-response-name-name","errorCode":null,"errorMessage":"Invalid value in server response: name=[${name}]","messagePattern":"Invalid value in server response: name=\\[(.+?)\\]","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java","lineNumber":333,"sourceCode":"      return null;\n    }\n\n    // ipAddr and xferPort are the critical fields for accessing data.\n    // If any one of the two is missing, an exception needs to be thrown.\n\n    // Handle the case of old servers (1.x, 0.23.x) sending 'name' instead\n    //  of ipAddr and xferPort.\n    String ipAddr = getString(m, \"ipAddr\", null);\n    int xferPort = getInt(m, \"xferPort\", -1);\n    if (ipAddr == null) {\n      String name = getString(m, \"name\", null);\n      if (name != null) {\n        int colonIdx = name.indexOf(':');\n        if (colonIdx > 0) {\n          ipAddr = name.substring(0, colonIdx);\n          xferPort = Integer.parseInt(name.substring(colonIdx +1));\n        } else {\n          throw new IOException(\n              \"Invalid value in server response: name=[\" + name + \"]\");\n        }\n      } else {\n        throw new IOException(\n            \"Missing both 'ipAddr' and 'name' in server response.\");\n      }\n      // ipAddr is non-null & non-empty string at this point.\n    }\n\n    // Check the validity of xferPort.\n    if (xferPort == -1) {\n      throw new IOException(\n          \"Invalid or missing 'xferPort' in server response.\");\n    }\n\n    // TODO: Fix storageID\n    return new DatanodeInfoBuilder().setIpAddr(ipAddr)\n        .setHostName((String) m.get(\"hostName\"))","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java#L315-L351","documentation":"When JsonUtilClient.toDatanodeInfo decodes a DataNode entry, it normally reads ipAddr and xferPort. For compatibility with old 1.x/0.23.x servers it can instead parse the legacy name field in host:port form. This IOException means name was present but had no colon at an index greater than zero, so no transfer address can be derived.","triggerScenarios":"A WebHDFS response containing block locations or DataNode status has a datanode object without ipAddr and with a name such as \"datanode-host\" or \":9866\". The parser therefore cannot split a host and xferPort. This can occur when a current client talks to a very old or nonstandard WebHDFS-compatible endpoint, or when a proxy rewrites datanode JSON.","commonSituations":"Mixing an old Hadoop 1.x/0.23.x server with a newer client; routing WebHDFS through a gateway that returns its own DataNode representation; a downstream service that manually constructs HDFS-like JSON; version drift in a test fixture.","solutions":["Point the client at a WebHDFS endpoint served by a Hadoop 2.x or later NameNode that emits ipAddr and xferPort.","Remove or fix a proxy/gateway that rewrites datanode location JSON, and verify it passes the NameNode response unchanged.","If the legacy server must remain, use a client version compatible with its response format or upgrade the server.","Inspect the raw GETFILEBLOCKLOCATIONS or open response and confirm each datanode object has ipAddr plus xferPort, or legacy name exactly host:port."],"exampleFix":"// before: response contains {\"name\": \"dn1\"}\nFileSystem fs = FileSystem.get(new URI(\"webhdfs://old-or-custom-gateway:9870\"), conf);\nFSDataInputStream in = fs.open(path);\n\n// after: endpoint returns {\"ipAddr\": \"10.0.0.5\", \"xferPort\": 9866}\nFileSystem fs = FileSystem.get(new URI(\"webhdfs://nn-hadoop2:9870\"), conf);\nFSDataInputStream in = fs.open(path);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return fs.open(path);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid value in server response\")) {\n    throw new IllegalStateException(\"WebHDFS endpoint returned a datanode name without host:port; check server/proxy compatibility\", e);\n  }\n  throw e;\n}","preventionTips":["Use a Hadoop client release that matches the cluster WebHDFS schema.","Do not rewrite datanode location JSON in reverse proxies or custom gateways.","Contract-test mocks and gateways against real WebHDFS GETFILEBLOCKLOCATIONS responses before deployment."],"tags":["java","hadoop","webhdfs","json","datanode","compatibility"],"backgroundTag":"malformed-server-response","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}