quarkusio/quarkus · error · IllegalArgumentException
Invalid integer encoding for a bit field type: " + bit + ".
Error message
Invalid integer encoding for a bit field type: " + bit + ". It must start with `i` (signed integers) or `u` (unsigned integers)
What it means
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.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/bitmap/BitFieldArgs.java:33
/**
* Represents a bit field type with details about signed/unsigned and the number of bits.
* Instances can be created from a boolean/bits or from strings like i8 (signed) or u10 (unsigned).
*/
public static class BitFieldType {
public final boolean signed;
public final int bits;
public BitFieldType(String bit) {
if (bit.startsWith("i")) {
this.signed = true;
this.bits = Integer.parseInt(bit.substring(1));
} else if (bit.startsWith("u")) {
this.signed = false;
this.bits = Integer.parseInt(bit.substring(1));
}
throw new IllegalArgumentException("Invalid integer encoding for a bit field type: " + bit +
". It must start with `i` (signed integers) or `u` (unsigned integers)");
}
public BitFieldType(boolean signed, int bits) {
if (bits <= 0) {
throw new IllegalArgumentException("`bits` must be strictly positive");
}
if (signed && bits >= 65) {
throw new IllegalArgumentException("Signed integers support only up to 64 bits");
}
if (!signed && bits >= 64) {
throw new IllegalArgumentException("Unsigned integers support only up to 63 bits");
}
this.signed = signed;
this.bits = bits;
}View on GitHub (pinned to e1c734241f)
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
Example fix
// before
BitFieldArgs args = new BitFieldArgs().set(new BitFieldArgs.BitFieldType("int8"), new BitFieldArgs.Offset(0), 5);
// after
BitFieldArgs args = new BitFieldArgs().set(new BitFieldArgs.BitFieldType("i8"), new BitFieldArgs.Offset(0), 5); Defensive patterns
Strategy: validation
Validate before calling
if (encoding == null || !(encoding.startsWith("i") || encoding.startsWith("u"))) { throw new IllegalArgumentException("encoding must start with i or u"); }
new BitFieldArgs.BitFieldType(encoding); Type guard
static boolean isValidBitFieldEncoding(String s) { return s != null && s.matches("[iu]\\d+"); } Try / catch
try { type = new BitFieldArgs.BitFieldType(encoding); } catch (IllegalArgumentException e) { type = BitFieldArgs.BitFieldType.unsignedIn8(); } Prevention
- Use BitFieldType factory constants instead of raw strings
- Normalize case (lowercase the prefix) for user input
- Regex-validate i/u + digits before constructing
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- `bits` must be strictly positive
- Signed integers support only up to 64 bits
- Unsigned integers support only up to 63 bits
- `offset` must be greater or equal to 0
- The offset must be greater or equals to 0
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/7069411739f01ed8.
Report an issue: GitHub.