quarkusio/quarkus · error · IllegalArgumentException

The BitFieldType must not be `null`

Error message

The BitFieldType must not be `null`

What it means

BitFieldArgs.set() validates the BitFieldType before emitting the SET sub-command. A null type is rejected with IllegalArgumentException because the type string (e.g. "i8") is required in the Redis command.

Source

Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/bitmap/BitFieldArgs.java:178

     * @param offset bitfield offset
     * @param value the value
     * @return the current {@code BitFieldArgs}
     */
    public BitFieldArgs set(BitFieldType bft, int offset, long value) {
        return set(bft, new Offset(false, offset), value);
    }

    /**
     * Adds a new {@code SET} subcommand.
     *
     * @param bft the bit field type, must not be {@code null}.
     * @param offset bitfield offset, must not be {@code null}.
     * @param value the value
     * @return the current {@code BitFieldArgs}
     */
    public BitFieldArgs set(BitFieldType bft, Offset offset, long value) {
        if (bft == null) {
            throw new IllegalArgumentException("The BitFieldType must not be `null`");
        }
        if (offset.offset < 0) {
            throw new IllegalArgumentException("The offset must be greater or equals to 0");
        }

        this.previousBitFieldType = bft;
        this.commands.addAll(List.of("SET", bft.toString(), offset.toString(), Long.toString(value)));
        return this;
    }

    /**
     * Adds a new {@code SET} subcommand using offset {@code 0} and the field type of the previous command.
     *
     * @param value the value
     * @return the current {@code BitFieldArgs}
     * @throws IllegalStateException if no previous field type was found
     */
    public BitFieldArgs set(long value) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass a non-null BitFieldType such as BitFieldArgs.BitFieldType.signIn8()
  2. Resolve a default field type when the configured one is missing
  3. Check for null before invoking set()

Example fix

// before
BitFieldArgs.BitFieldType type = types.get(name); // may be null
args.set(type, offset, value);
// after
BitFieldArgs.BitFieldType type = types.getOrDefault(name, BitFieldArgs.BitFieldType.unsignedIn8());
args.set(type, offset, value);
Defensive patterns

Strategy: type-guard

Validate before calling

Objects.requireNonNull(bft, "BitFieldType required");
args.set(bft, offset, value);

Type guard

static boolean isNonNullType(BitFieldArgs.BitFieldType t) { return t != null; }

Try / catch

try { args.set(bft, offset, value); } catch (IllegalArgumentException e) { args.set(BitFieldArgs.BitFieldType.unsignedIn8(), offset, value); }

Prevention

When it happens

Trigger: args.set(null, offset, value), usually when the BitFieldType came from a cache/lookup that returned null or from an uninitialized field.

Common situations: Field type resolved from config that is absent; null returned by a map lookup; variable declared but never assigned.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/78dfc16c7c358ed8. Report an issue: GitHub.