{"record":{"id":"f3fb719edaaceae4","repo":"apache/iceberg","slug":"unable-to-produce-hash-of-table-metadata","errorCode":null,"errorMessage":"Unable to produce hash of table metadata","messagePattern":"Unable to produce hash of table metadata","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java","lineNumber":305,"sourceCode":"    byte[] expectedHashBytes = Base64.getDecoder().decode(metadataHashFromHMS);\n\n    if (!Arrays.equals(expectedHashBytes, currentHashBytes)) {\n      throw new RuntimeException(\n          String.format(\n              \"The current metadata file %s might have been modified. Hash of metadata loaded from storage differs \"\n                  + \"from HMS-stored metadata hash.\",\n              metadata.metadataFileLocation()));\n    }\n  }\n\n  private static byte[] hashOf(TableMetadata tableMetadata) {\n    try (HashWriter hashWriter = new HashWriter(\"SHA-256\", StandardCharsets.UTF_8);\n        JsonGenerator generator = JsonUtil.factory().createGenerator(hashWriter)) {\n      TableMetadataParser.toJson(tableMetadata, generator);\n      generator.flush();\n      return hashWriter.getHash();\n    } catch (NoSuchAlgorithmException | IOException e) {\n      throw new RuntimeException(\"Unable to produce hash of table metadata\", e);\n    }\n  }\n\n  private static void setField(\n      Map<String, String> parameters, String key, String value, long maxHiveTablePropertySize) {\n    if (value.length() <= maxHiveTablePropertySize) {\n      parameters.put(key, value);\n    } else {\n      LOG.warn(\n          \"Not exposing {} in HMS since it exceeds {} characters\", key, maxHiveTablePropertySize);\n    }\n  }\n\n  private static boolean exposeInHmsProperties(long maxHiveTablePropertySize) {\n    return maxHiveTablePropertySize > 0;\n  }\n}\n","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HMSTablePropertyHelper.java#L287-L323","documentation":"HMSTablePropertyHelper.hashOf() throws RuntimeException when it fails to serialize TableMetadata to JSON or compute its SHA-256 hash, e.g. NoSuchAlgorithmException (SHA-256 unavailable) or IOException from the JSON generator/hash writer plumbing.","triggerScenarios":"Computing the metadata hash during table property updates when the JVM lacks the SHA-256 algorithm or the JsonGenerator/HashWriter pipeline throws IOException.","commonSituations":"Running on a restricted JRE without SHA-256 (rare); I/O errors in the in-memory hash stream; bugs in metadata parser serialization.","solutions":["Use a standard JDK/JCE provider that includes SHA-256","Inspect the chained cause for the actual serialization/IO problem","Report/fix if TableMetadataParser.toJson fails on specific metadata content"],"exampleFix":"// before\nnew HashWriter(\"SHA-256\", ...); // NoSuchAlgorithmException\n// after\n// run on full JDK (e.g. Temurin) where SHA-256 is always available","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* property update path */ } catch (RuntimeException e) { if (e.getCause() instanceof NoSuchAlgorithmException || e.getCause() instanceof IOException) { /* handle serialization failure */ } }","preventionTips":["Run on a full JDK with standard JCE providers","Keep Iceberg version current (parser fixes)","Surface chained causes in logs"],"tags":["hive","metadata","hashing","internal"],"backgroundTag":"json-marshal-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}