{"record":{"id":"7069411739f01ed8","repo":"quarkusio/quarkus","slug":"invalid-integer-encoding-for-a-bit-field-type","errorCode":null,"errorMessage":"Invalid integer encoding for a bit field type: \" + bit + \". It must start with `i` (signed integers) or `u` (unsigned integers)","messagePattern":"Invalid integer encoding for a bit field type: \" \\+ bit \\+ \"\\. It must start with `i` \\(signed integers\\) or `u` \\(unsigned integers\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/bitmap/BitFieldArgs.java","lineNumber":33,"sourceCode":"\n    /**\n     * Represents a bit field type with details about signed/unsigned and the number of bits.\n     * Instances can be created from a boolean/bits or from strings like i8 (signed) or u10 (unsigned).\n     */\n    public static class BitFieldType {\n\n        public final boolean signed;\n        public final int bits;\n\n        public BitFieldType(String bit) {\n            if (bit.startsWith(\"i\")) {\n                this.signed = true;\n                this.bits = Integer.parseInt(bit.substring(1));\n            } else if (bit.startsWith(\"u\")) {\n                this.signed = false;\n                this.bits = Integer.parseInt(bit.substring(1));\n            }\n            throw new IllegalArgumentException(\"Invalid integer encoding for a bit field type: \" + bit +\n                    \". It must start with `i` (signed integers) or `u` (unsigned integers)\");\n        }\n\n        public BitFieldType(boolean signed, int bits) {\n            if (bits <= 0) {\n                throw new IllegalArgumentException(\"`bits` must be strictly positive\");\n            }\n\n            if (signed && bits >= 65) {\n                throw new IllegalArgumentException(\"Signed integers support only up to 64 bits\");\n            }\n            if (!signed && bits >= 64) {\n                throw new IllegalArgumentException(\"Unsigned integers support only up to 63 bits\");\n            }\n\n            this.signed = signed;\n            this.bits = bits;\n        }","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/bitmap/BitFieldArgs.java#L15-L51","documentation":"BitFieldArgs.BitFieldType(String) parses a Redis-style encoding string like \"i8\" or \"u5\" (signed/unsigned integer with a bit width). If the string does not start with 'i' or 'u', the constructor cannot interpret it and throws IllegalArgumentException. The parsing branch falls through to the throw because no prefix matched.","triggerScenarios":"new BitFieldArgs.BitFieldType(\"signed\"), BitFieldType(\"i\"), BitFieldType(\"U8\"), or any string missing the i/u prefix (e.g. an uppercase letter or a number like \"64\") passed as the bit-field type encoding.","commonSituations":"Passing a config value like \"int\" or \"uint\" instead of Redis notation; case-sensitivity mistakes (\"I8\" instead of \"i8\"); forgetting the bit width suffix is not the issue — the prefix is.","solutions":["Use the i or u prefix followed by the bit width, e.g. \"i8\", \"u64\"","Use the BitFieldArgs.BitFieldType factory constants (signIn8, unsignedIn8, etc.) instead of raw strings","Lowercase the prefix before constructing if the value comes from user input"],"exampleFix":"// before\nBitFieldArgs args = new BitFieldArgs().set(new BitFieldArgs.BitFieldType(\"int8\"), new BitFieldArgs.Offset(0), 5);\n// after\nBitFieldArgs args = new BitFieldArgs().set(new BitFieldArgs.BitFieldType(\"i8\"), new BitFieldArgs.Offset(0), 5);","handlingStrategy":"validation","validationCode":"if (encoding == null || !(encoding.startsWith(\"i\") || encoding.startsWith(\"u\"))) { throw new IllegalArgumentException(\"encoding must start with i or u\"); }\nnew BitFieldArgs.BitFieldType(encoding);","typeGuard":"static boolean isValidBitFieldEncoding(String s) { return s != null && s.matches(\"[iu]\\\\d+\"); }","tryCatchPattern":"try { type = new BitFieldArgs.BitFieldType(encoding); } catch (IllegalArgumentException e) { type = BitFieldArgs.BitFieldType.unsignedIn8(); }","preventionTips":["Use BitFieldType factory constants instead of raw strings","Normalize case (lowercase the prefix) for user input","Regex-validate i/u + digits before constructing"],"tags":["redis","bitfield","argument-validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}