apache/hadoop · error · IOException
JSON parser error, {0}
Error message
JSON parser error, {0} What it means
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.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSFileSystem.java:1403
xAttrs.put(name, value);
}
return xAttrs;
}
/** Convert xAttr names json to names list */
private List<String> createXAttrNames(String xattrNamesStr) throws IOException {
JSONParser parser = new JSONParser();
JSONArray jsonArray;
try {
jsonArray = (JSONArray)parser.parse(xattrNamesStr);
List<String> names = Lists.newArrayListWithCapacity(jsonArray.size());
for (Object name : jsonArray) {
names.add((String) name);
}
return names;
} catch (ParseException e) {
throw new IOException("JSON parser error, " + e.getMessage(), e);
}
}
@Override
public Map<String, byte[]> getXAttrs(Path f) throws IOException {
Map<String, String> params = new HashMap<String, String>();
params.put(OP_PARAM, Operation.GETXATTRS.toString());
HttpURLConnection conn = getConnection(Operation.GETXATTRS.getMethod(),
params, f, true);
HttpExceptionUtils.validateResponse(conn, HttpURLConnection.HTTP_OK);
JSONObject json = (JSONObject) HttpFSUtils.jsonParse(conn);
return createXAttrMap((JSONArray) json.get(XATTRS_JSON));
}
@Override
public Map<String, byte[]> getXAttrs(Path f, List<String> names)
throws IOException {
Preconditions.checkArgument(names != null && !names.isEmpty(), View on GitHub (pinned to 2add963021)
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
Defensive patterns
Strategy: try-catch
Try / catch
try {
Map<String, byte[]> x = fs.getXAttrs(path);
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().startsWith("JSON parser error")) {
// server sent malformed xattr JSON: capture raw response with curl and compare client/server versions
LOG.error("Malformed GETXATTRS response for {}", path, e);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- JSON parser error, {0}
- Attribute with name {} is not found.
- Attributes with name {} are not found.
- XAttr: {} already exists. The REPLACE flag must be specified
- XAttr: {} does not exist. The CREATE flag must be specified.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/5bdcb074b07e4881.
Report an issue: GitHub.