{"record":{"id":"d269782431da1efa","repo":"apache/cassandra","slug":"size-has-to-be-strictly-positive-number-it-is-d","errorCode":null,"errorMessage":"Size has to be strictly positive number, it is '<dictLength>'.","messagePattern":"Size has to be strictly positive number, it is '<dictLength>'\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compression/CompressionDictionaryDetailsTabularData.java","lineNumber":312,"sourceCode":"                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 + \"'.\");\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":294,"sourceCodeEnd":328,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compression/CompressionDictionaryDetailsTabularData.java#L294-L328","documentation":"The declared dictionary length (dictLength) must be a strictly positive number. validate() rejects dictLength <= 0 before comparing it to the actual byte array length, ensuring the descriptor always declares a meaningful payload size.","triggerScenarios":"Constructing a CompressionDictionaryDataObject with dictLength = 0 or negative — typically an unset numeric field (default 0) or a length variable computed from an empty/failed read.","commonSituations":"Import tooling where the length field defaulted to 0; lengths parsed from a truncated metadata source; callers passing byte count of an empty buffer.","solutions":["Set dictLength to the actual number of bytes in the dictionary payload (dict.length)","If reading from a file, use the file size after verifying it is non-empty","Initialize the length field rather than leaving it at its numeric default"],"exampleFix":"// before\nint dictLength = 0; // unset\n// after\nint dictLength = dict.length;","handlingStrategy":"validation","validationCode":"if (obj.dictLength <= 0) throw new IllegalArgumentException(\"dictLength must be positive, got: \" + obj.dictLength);","typeGuard":"boolean hasPositiveLength(CompressionDictionaryDataObject o) { return o.dictLength > 0; }","tryCatchPattern":"try { tabularData.fromDataObject(obj); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Size has to be strictly positive\")) { /* set dictLength = dict.length and rebuild */ } else throw e; }","preventionTips":["Derive dictLength directly from dict.length so it can never default to 0","Avoid unset numeric defaults; compute lengths at construction time","Check the payload was actually loaded before declaring its length"],"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-17T15:17:12.973Z"}