{"record":{"id":"47b0baeec541e4fb","repo":"apache/cassandra","slug":"computed-checksum-of-dictionary-to-import-s-is","errorCode":null,"errorMessage":"Computed checksum of dictionary to import (%s) is different from checksum specified on input (%s).","messagePattern":"Computed checksum of dictionary to import \\((.+?)\\) is different from checksum specified on input \\((.+?)\\)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compression/CompressionDictionaryDetailsTabularData.java","lineNumber":321,"sourceCode":"            {\n                dictionaryKind = CompressionDictionary.Kind.valueOf(kind);\n            }\n            catch (IllegalArgumentException ex)\n            {\n                throw new IllegalArgumentException(\"There is no such dictionary kind like '\" + kind + \"'. Available kinds: \" + Arrays.asList(CompressionDictionary.Kind.values()));\n            }\n\n            if (dictLength <= 0)\n                throw new IllegalArgumentException(\"Size has to be strictly positive number, it is '\" + dictLength + \"'.\");\n            if (dict.length != dictLength)\n                throw new IllegalArgumentException(\"The length of the provided dictionary array (\" + dict.length + \") is not equal to provided length value (\" + dictLength + \").\");\n            if (createdAt == null)\n                throw new IllegalArgumentException(\"The creation date not specified.\");\n\n            int checksumOfDictionaryToImport = CompressionDictionary.calculateChecksum((byte) dictionaryKind.ordinal(), dictId, dict);\n            if (checksumOfDictionaryToImport != dictChecksum)\n            {\n                throw new IllegalArgumentException(format(\"Computed checksum of dictionary to import (%s) is different from checksum specified on input (%s).\",\n                                                          checksumOfDictionaryToImport,\n                                                          dictChecksum));\n            }\n        }\n    }\n}\n","sourceCodeStart":303,"sourceCodeEnd":328,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compression/CompressionDictionaryDetailsTabularData.java#L303-L328","documentation":"When importing a compression dictionary, Cassandra recomputes the checksum of the dictionary bytes (combined with the dictionary kind ordinal and dict id) via CompressionDictionary.calculateChecksum and compares it against the checksum supplied in the import data. If they differ, the input is corrupt or the metadata was edited, and the import is rejected with IllegalArgumentException. This protects nodes from loading a dictionary whose contents do not match what was originally trained.","triggerScenarios":"Calling CompressionDictionaryManager.importCompressionDictionary (or the JMX/MBean equivalent) with a CompressionDictionaryDataObject whose dictChecksum field does not match CompressionDictionary.calculateChecksum(kind.ordinal(), dictId, dict) computed from the payload.","commonSituations":"Hand-editing or truncating the dictionary bytes when exporting/importing between clusters; copying dictionary data through a lossy channel (text transformation, wrong encoding); constructing the CompositeData manually with a stale or wrong checksum; exporting from one version and importing into another with a changed checksum algorithm.","solutions":["Recompute the checksum with CompressionDictionary.calculateChecksum((byte) kind.ordinal(), dictId, dict) and set that value as dictChecksum in the data object before import.","Re-export the dictionary from the source cluster using the provided export tooling instead of copying bytes by hand.","Verify the dictionary bytes were not modified in transit (use binary-safe transfer; avoid text encoding/decoding).","Confirm both source and target run compatible Cassandra versions with the same checksum algorithm."],"exampleFix":"// before\nCompressionDictionaryDataObject data = new CompressionDictionaryDataObject(keyspace, table, kind, dictId, dict, staleChecksum);\n// after\nint checksum = CompressionDictionary.calculateChecksum((byte) dictionaryKind.ordinal(), dictId, dict);\nCompressionDictionaryDataObject data = new CompressionDictionaryDataObject(keyspace, table, kind, dictId, dict, checksum);","handlingStrategy":"validation","validationCode":"int expected = CompressionDictionary.calculateChecksum((byte) kind.ordinal(), dictId, dict);\nif (expected != dataObject.dictChecksum) throw new IllegalArgumentException(\"checksum mismatch before import\");","typeGuard":null,"tryCatchPattern":"try { manager.importCompressionDictionary(data); } catch (IllegalArgumentException e) { /* checksum mismatch: re-export dictionary */ }","preventionTips":["Always export/import dictionaries with the built-in tooling, never hand-copy bytes","Use binary-safe channels for dictionary transfer","Recompute checksums on the exporting side right before export"],"tags":["compression","dictionary-import","checksum"],"backgroundTag":"checksum-mismatch","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}