{"record":{"id":"9365cf4016842665","repo":"apache/cassandra","slug":"provided-dictionary-id-must-be-positive-but-it-is","errorCode":null,"errorMessage":"Provided dictionary id must be positive but it is '<dictId>'.","messagePattern":"Provided dictionary id must be positive but it is '<dictId>'\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compression/CompressionDictionaryDetailsTabularData.java","lineNumber":294,"sourceCode":"         *     <li>dict is not null nor empty</li>\n         *     <li>dict length is less than or equal to 1MiB</li>\n         *     <li>kind is not null and there is such {@link org.apache.cassandra.db.compression.CompressionDictionary.Kind}</li>\n         *     <li>dictLength is bigger than 0</li>\n         *     <li>dictLength has to be equal to dict's length</li>\n         *     <li>dictChecksum has to be equal to checksum computed as part of this method</li>\n         *     <li>creation date is not null</li>\n         * </ul>\n         */\n        private void validate()\n        {\n            if (keyspace == null)\n                throw new IllegalArgumentException(\"Keyspace not specified.\");\n            if (table == null)\n                throw new IllegalArgumentException(\"Table not specified.\");\n            if (tableId == null)\n                throw new IllegalArgumentException(\"Table id not specified.\");\n            if (dictId <= 0)\n                throw new IllegalArgumentException(\"Provided dictionary id must be positive but it is '\" + dictId + \"'.\");\n            if (dict == null || dict.length == 0)\n                throw new IllegalArgumentException(\"Provided dictionary byte array is null or empty.\");\n            if (kind == null)\n                throw new IllegalArgumentException(\"Provided kind is null.\");\n\n            CompressionDictionary.Kind dictionaryKind;\n\n            try\n            {\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 + \"'.\");","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compression/CompressionDictionaryDetailsTabularData.java#L276-L312","documentation":"The dictionary id must be a strictly positive integer; validate() rejects dictId <= 0 and includes the offending value in the message. Dictionary ids are assigned by Cassandra and used as the unique identifier of the dictionary, so zero or negative values are invalid by contract.","triggerScenarios":"Constructing a CompressionDictionaryDataObject with dictId set to 0, a negative number, or an unset/zero-initialized numeric field (e.g. a Java long/int field defaulted to 0).","commonSituations":"Hand-built descriptors where the id was never populated (defaulting to 0); parsing errors that yield 0; callers confusing an index (0-based) with a dictionary id (positive).","solutions":["Supply the real positive dictionary id (as reported by LIST COMPRESSION DICTIONARIES or the JMX interface)","If the id is unknown, fetch it from the system.compression_dict table instead of guessing","Check that the numeric field has been initialized, not left at its 0 default"],"exampleFix":"// before\nlong dictId = 0; // unset default\n// after\nlong dictId = existingDictionary.id().asLong(); // positive id from the stored dictionary","handlingStrategy":"validation","validationCode":"if (obj.dictId <= 0) throw new IllegalArgumentException(\"dictId must be positive, got: \" + obj.dictId);","typeGuard":"boolean hasPositiveDictId(CompressionDictionaryDataObject o) { return o.dictId > 0; }","tryCatchPattern":"try { tabularData.fromDataObject(obj); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Provided dictionary id must be positive\")) { /* fetch the real id from system.compression_dict */ } else throw e; }","preventionTips":["Take dictId from the stored dictionary metadata rather than hand-entering it","Watch for default-0 numeric fields; use boxed types or explicit initialization","Remember ids are positive — 0-based indices are not valid dictionary ids"],"tags":["validation","compression-dictionary"],"backgroundTag":"value-out-of-range","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"}