{"record":{"id":"47e7cfb13bfc96f2","repo":"apache/hadoop","slug":"content-type-0-is-incompatible-with-applicati","errorCode":null,"errorMessage":"Content-Type \"{0}\" is incompatible with \"application/json\" (parsed=\"{1}\")","messagePattern":"Content-Type \"(.+?)\" is incompatible with \"application/json\" \\(parsed=\"(.+?)\"\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSUtils.java","lineNumber":138,"sourceCode":"\n  /**\n   * Convenience method that JSON Parses the <code>InputStream</code> of a\n   * <code>HttpURLConnection</code>.\n   *\n   * @param conn the <code>HttpURLConnection</code>.\n   *\n   * @return the parsed JSON object.\n   *\n   * @throws IOException thrown if the <code>InputStream</code> could not be\n   * JSON parsed.\n   */\n  public static Object jsonParse(HttpURLConnection conn) throws IOException {\n    try {\n      String contentType = conn.getContentType();\n      if (contentType != null) {\n        final MediaType parsed = MediaType.valueOf(contentType);\n        if (!MediaType.APPLICATION_JSON_TYPE.isCompatible(parsed)) {\n          throw new IOException(\"Content-Type \\\"\" + contentType\n              + \"\\\" is incompatible with \\\"\" + MediaType.APPLICATION_JSON\n              + \"\\\" (parsed=\\\"\" + parsed + \"\\\")\");\n        }\n      }\n      JSONParser parser = new JSONParser();\n      return parser.parse(\n          new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));\n    } catch (ParseException ex) {\n      throw new IOException(\"JSON parser error, \" + ex.getMessage(), ex);\n    }\n  }\n}\n","sourceCodeStart":120,"sourceCodeEnd":151,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/fs/http/client/HttpFSUtils.java#L120-L151","documentation":"HttpFSUtils.jsonParse() refuses to parse a response unless its Content-Type is compatible with application/json (checked via JAX-RS MediaType.isCompatible). A non-JSON content type (text/html, text/plain, application/octet-stream...) triggers this IOException listing the actual type. It fires before any parsing, so it is a reliable signal that something other than the HttpFS JSON API answered the request.","triggerScenarios":"Any metadata operation (GETFILESTATUS, LISTSTATUS, GETXATTRS...) where a gateway returns an HTML login/error page, an auth challenge body, or where the request lands on a non-HttpFS servlet that answers with text/plain or a binary stream.","commonSituations":"Kerberos/SSO proxy in front of HttpFS returning an HTML form with status 200; nginx serving a static maintenance page; wrong port hitting a different webapp; MIME-mangling middleware between client and server.","solutions":["curl -i the failing WebHDFS URL and read the actual Content-Type and body to identify who answered","Fix or bypass the intermediary: exempt /webhdfs/v1 from the HTML-producing auth/error pages, or authenticate properly so the JSON API responds","Point the webhdfs:// URI at the real HttpFS/WebHDFS host:port","Confirm httpfs-site.xml authentication type (simple vs kerberos) matches what the client presents, so no interstitial page is returned"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  FileStatus st = fs.getFileStatus(path);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"is incompatible with\")) {\n    // a non-JSON page (auth form, error page) answered instead of the HttpFS API\n    LOG.error(\"Non-JSON response from {} - check auth/proxy in front of HttpFS\", fs.getUri());\n  }\n  throw e;\n}","preventionTips":["curl -i the WebHDFS endpoint after any proxy/auth-layer change and assert Content-Type: application/json","Keep authentication mode (simple/kerberos) consistent between client config and httpfs-site.xml","Alert on text/html responses from /webhdfs/v1 URLs as a proxy-misconfiguration signal"],"tags":["webhdfs","httpfs","content-type","json","proxy"],"backgroundTag":"wrong-content-type","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}