{"record":{"id":"f1c69ba5f12fff9b","repo":"apache/hadoop","slug":"missing-both-ipaddr-and-name-in-server-respons","errorCode":null,"errorMessage":"Missing both 'ipAddr' and 'name' in server response.","messagePattern":"Missing both 'ipAddr' and 'name' in server response\\.","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":337,"sourceCode":"    // 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\"))\n        .setDatanodeUuid((String) m.get(\"storageID\")).setXferPort(xferPort)\n        .setInfoPort(((Number) m.get(\"infoPort\")).intValue())\n        .setInfoSecurePort(getInt(m, \"infoSecurePort\", 0))\n        .setIpcPort(((Number) m.get(\"ipcPort\")).intValue())","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java#L319-L355","documentation":"JsonUtilClient.toDatanodeInfo requires either the modern ipAddr field or the old 1.x/0.23.x name field to identify a DataNode. If both keys are absent from a datanode JSON object, the client cannot construct the address needed to transfer blocks and throws this IOException.","triggerScenarios":"Any API whose WebHDFS response contains datanode locations, such as open, getFileBlockLocations, or listLocatedStatus, receives a datanode map with neither ipAddr nor name. This generally indicates a non-WebHDFS endpoint, a proxy-generated JSON body, or a server/client version that does not share a response schema.","commonSituations":"Calling a REST service that mimics WebHDFS but omits DataNode fields; a reverse proxy returning its own JSON error object with HTTP 200; a mock server built from a different Hadoop version; a partially upgraded cluster.","solutions":["Verify the URL is a real WebHDFS NameNode endpoint, normally http(s)://namenode:port/webhdfs/v1/..., rather than a gateway or management API.","Upgrade the old server or use a client release matching the server response schema.","Fix a custom proxy or mock so datanode objects include ipAddr and xferPort.","Capture the raw response and inspect its datanode entries before retrying, because this is a schema error and retrying unchanged will fail again."],"exampleFix":"// before\nFileSystem fs = FileSystem.get(new URI(\"webhdfs://gateway:9870\"), conf);\nRemoteIterator<LocatedFileStatus> files = fs.listFiles(path, true);\n\n// after: use the NameNode WebHDFS endpoint directly\nFileSystem fs = FileSystem.get(new URI(\"webhdfs://namenode:9870\"), conf);\nRemoteIterator<LocatedFileStatus> files = fs.listFiles(path, true);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return fs.getFileBlockLocations(path, start, len);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Missing both 'ipAddr' and 'name'\")) {\n    throw new IllegalStateException(\"Endpoint did not return WebHDFS-compatible datanode objects\", e);\n  }\n  throw e;\n}","preventionTips":["Validate integration-test endpoints against the real WebHDFS NameNode schema, not a generic JSON service.","Bypass response-rewriting proxies when diagnosing datanode decoding errors.","Pin client and server Hadoop versions during rolling upgrades until both use the same schema."],"tags":["java","hadoop","webhdfs","json","datanode","schema"],"backgroundTag":"malformed-server-response","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}