{"record":{"id":"5bdcb074b07e4881","repo":"apache/hadoop","slug":"json-parser-error-0","errorCode":null,"errorMessage":"JSON parser error, {0}","messagePattern":"JSON parser error, (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java","lineNumber":1403,"sourceCode":"      xAttrs.put(name, value);\n    }\n\n    return xAttrs;\n  }\n\n  /** Convert xAttr names json to names list */\n  private List<String> createXAttrNames(String xattrNamesStr) throws IOException {\n    JSONParser parser = new JSONParser();\n    JSONArray jsonArray;\n    try {\n      jsonArray = (JSONArray)parser.parse(xattrNamesStr);\n      List<String> names = Lists.newArrayListWithCapacity(jsonArray.size());\n      for (Object name : jsonArray) {\n        names.add((String) name);\n      }\n      return names;\n    } catch (ParseException e) {\n      throw new IOException(\"JSON parser error, \" + e.getMessage(), e);\n    }\n  }\n\n  @Override\n  public Map<String, byte[]> getXAttrs(Path f) throws IOException {\n    Map<String, String> params = new HashMap<String, String>();\n    params.put(OP_PARAM, Operation.GETXATTRS.toString());\n    HttpURLConnection conn = getConnection(Operation.GETXATTRS.getMethod(),\n        params, f, true);\n    HttpExceptionUtils.validateResponse(conn, HttpURLConnection.HTTP_OK);\n    JSONObject json = (JSONObject) HttpFSUtils.jsonParse(conn);\n    return createXAttrMap((JSONArray) json.get(XATTRS_JSON));\n  }\n\n  @Override\n  public Map<String, byte[]> getXAttrs(Path f, List<String> names)\n      throws IOException {\n    Preconditions.checkArgument(names != null && !names.isEmpty(), ","sourceCodeStart":1385,"sourceCodeEnd":1421,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java#L1385-L1421","documentation":"HttpFSFileSystem.createXAttrNames() parses the server's getXAttrs response (a JSON array of xattr names) with json-simple after the content-type check in HttpFSUtils.jsonParse has already passed. A ParseException is wrapped into IOException(\"JSON parser error, \" + cause), so this specific message means the body claimed to be JSON but failed to parse as the expected structure. It indicates a malformed or structurally different server response, not a bad client call.","triggerScenarios":"fs.getXAttrs(path) or fs.getXAttrs(path, names) where the HttpFS server returns a corrupted body, a proxy truncates the stream, or a server version serializes the xattr-names array in a shape the client jar's parser rejects (e.g., object instead of array, which surfaces as a parse failure inside the loop cast).","commonSituations":"Client/server Hadoop version skew (2.x client against 3.x server or vice versa); an intermediary rewriting response bodies; a server-side bug in xattr JSON serialization after an upgrade.","solutions":["Inspect the raw response: curl -i 'http://host:14000/webhdfs/v1/<path>?op=GETXATTRS&user.name=...' and confirm it is a valid JSON array","Match client hadoop-hdfs-httpfs version to the server version to eliminate protocol/serialization drift","Remove or fix any proxy/filter that mutates response bodies on the HttpFS path","If the body is valid JSON but not an array, check the server log for the executor that produced it and report a server bug"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  Map<String, byte[]> x = fs.getXAttrs(path);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"JSON parser error\")) {\n    // server sent malformed xattr JSON: capture raw response with curl and compare client/server versions\n    LOG.error(\"Malformed GETXATTRS response for {}\", path, e);\n  }\n  throw e;\n}","preventionTips":["Keep webhdfs client and HttpFS server on matching versions in your distribution","Add a canary getXAttrs call in integration tests to catch serialization drift before prod","Do not put body-rewriting middleware on the /webhdfs/v1 path"],"tags":["webhdfs","xattr","json-parse","client-server-skew"],"backgroundTag":"malformed-json-response","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}