{"record":{"id":"c158d43563f52c3d","repo":"apache/hadoop","slug":"unknown-algorithm-algorithm","errorCode":null,"errorMessage":"Unknown algorithm: ${algorithm}","messagePattern":"Unknown algorithm: (.+?)","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":562,"sourceCode":"    final int length = ((Number) m.get(\"length\")).intValue();\n    final byte[] bytes = StringUtils.hexStringToByte((String) m.get(\"bytes\"));\n\n    final DataInputStream in = new DataInputStream(\n        new ByteArrayInputStream(bytes));\n    final DataChecksum.Type crcType =\n        MD5MD5CRC32FileChecksum.getCrcTypeFromAlgorithmName(algorithm);\n    final MD5MD5CRC32FileChecksum checksum;\n\n    // Recreate what DFSClient would have returned.\n    switch(crcType) {\n    case CRC32:\n      checksum = new MD5MD5CRC32GzipFileChecksum();\n      break;\n    case CRC32C:\n      checksum = new MD5MD5CRC32CastagnoliFileChecksum();\n      break;\n    default:\n      throw new IOException(\"Unknown algorithm: \" + algorithm);\n    }\n    checksum.readFields(in);\n\n    //check algorithm name\n    if (!checksum.getAlgorithmName().equals(algorithm)) {\n      throw new IOException(\"Algorithm not matched. Expected \" + algorithm\n          + \", Received \" + checksum.getAlgorithmName());\n    }\n    //check length\n    if (length != checksum.getLength()) {\n      throw new IOException(\"Length not matched: length=\" + length\n          + \", checksum.getLength()=\" + checksum.getLength());\n    }\n\n    return checksum;\n  }\n\n  /** Convert a Json map to a AclStatus object. */","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/JsonUtilClient.java#L544-L580","documentation":"JsonUtilClient.toMD5MD5CRC32FileChecksum converts the JSON returned by WebHDFS GETFILECHECKSUM into an MD5MD5CRC32FileChecksum. The client-side reconstruction supports only CRC32 and CRC32C checksum families. The default branch throws this IOException when the checksum algorithm advertised by the server resolves to an unsupported type.","triggerScenarios":"Calling FileSystem.getFileChecksum(path) through webhdfs:// or swebhdfs:// when the response's FileChecksum.algorithm does not represent one of the supported CRC32 or CRC32C MD5 composite checksums. This can happen with a nonstandard server, a proxy-modified response, or a Hadoop version whose checksum representation is not understood by this client.","commonSituations":"A WebHDFS gateway generates checksums in another format; a client is older or newer than the cluster; a test mock returns a generic algorithm string; an intermediary rewrites the JSON checksum object.","solutions":["Run the same getFileChecksum operation with a Hadoop client release matching the cluster to confirm the algorithm is supported end to end.","Point directly at the cluster WebHDFS endpoint and remove any gateway that rewrites checksum JSON.","Upgrade the client or server to versions that both support the checksum type in use.","If an unsupported checksum type is expected, compute an application-level digest by reading the file instead of relying on getFileChecksum."],"exampleFix":"// before\nFileChecksum checksum = fs.getFileChecksum(path); // algorithm unsupported by client\n\n// after: fall back to reading the bytes when WebHDFS cannot decode the server checksum\ntry {\n  return fs.getFileChecksum(path);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unknown algorithm\")) {\n    return computeDigestByReading(fs.open(path));\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return fs.getFileChecksum(path);\n} catch (IOException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Unknown algorithm\")) {\n    return computeDigestByReading(fs.open(path));\n  }\n  throw e;\n}","preventionTips":["Use a client version compatible with every checksum type configured in the cluster.","Do not replace GETFILECHECKSUM responses in proxies or mocks.","Have applications that require portability compute their own digest instead of depending on cluster-specific checksum families."],"tags":["java","hadoop","webhdfs","checksum","compatibility"],"backgroundTag":"unsupported-checksum-algorithm","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}