{"record":{"id":"4841ef275fe58005","repo":"apache/cassandra","slug":"invalid-compression-dictionary-kind-s","errorCode":null,"errorMessage":"Invalid compression dictionary kind: %s","messagePattern":"Invalid compression dictionary kind: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compression/CompressionDictionary.java","lineNumber":231,"sourceCode":"     * @throws IOException on any I/O exception when reading from the file\n     */\n    @Nullable\n    static CompressionDictionary deserialize(DataInput input, @Nullable CompressionDictionaryManager manager) throws IOException\n    {\n        int kindOrdinal;\n        try\n        {\n            kindOrdinal = input.readByte();\n        }\n        catch (EOFException eof)\n        {\n            // no dictionary\n            return null;\n        }\n\n        if (kindOrdinal < 0 || kindOrdinal >= Kind.values().length)\n        {\n            throw new IOException(\"Invalid compression dictionary kind: \" + kindOrdinal);\n        }\n        Kind kind = Kind.values()[kindOrdinal];\n        long id = input.readLong();\n        DictId dictId = new DictId(kind, id);\n\n        if (manager != null)\n        {\n            CompressionDictionary dictionary = manager.get(dictId);\n            if (dictionary != null)\n            {\n                return dictionary;\n            }\n        }\n\n        int length = input.readInt();\n        byte[] dict = new byte[length];\n        input.readFully(dict);\n        int checksum = input.readInt();","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compression/CompressionDictionary.java#L213-L249","documentation":"CompressionDictionary.deserialize reads a dictionary from a stream: the first field is an ordinal indexing the Kind enum. If the ordinal is negative or beyond the number of known kinds, the stream is corrupted, written by an incompatible/newer version, or truncated, so an IOException is thrown rather than indexing out of bounds.","triggerScenarios":"Reading a serialized compression dictionary (dictionary file or system table blob) whose kind ordinal byte/int falls outside [0, Kind.values().length).","commonSituations":"Upgrading/downgrading between Cassandra versions with different Kind sets, corrupted SSTable or dictionary files, hand-edited or partially written files.","solutions":["Verify the dictionary file/table data is intact and complete (check file sizes, re-transfer).","Ensure the node version supports the dictionary kind that wrote the data; align cluster versions.","Regenerate the dictionary (e.g. re-create zstd dictionary training) if the source is unrecoverable.","Restore the affected SSTables/files from backup."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    dict = CompressionDictionary.deserialize(input, manager);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Invalid compression dictionary kind\")) { retransferOrRegenerateDictionary(); }\n    else throw e;\n}","preventionTips":["Keep cluster node versions aligned for zstd dictionary features","Verify file integrity (checksums) when copying dictionary files between nodes","Back up dictionary files and system tables before upgrades"],"tags":["cassandra","compression","deserialization","zstd-dictionary"],"backgroundTag":"invalid-enum-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}