quarkusio/quarkus · error · IllegalArgumentException

`btf` must not be `null`

Error message

`btf` must not be `null`

What it means

BitFieldArgs.incrBy() validates its BitFieldType parameter and throws IllegalArgumentException when it is null, because the INCRBY sub-command requires the type encoding string. (Note the message says `btf` while the parameter is named `bft` — same check.)

Source

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

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

    /**
     * Adds a new {@code INCRBY} 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 incrBy(BitFieldType bft, Offset offset, long value) {
        if (bft == null) {
            throw new IllegalArgumentException("`btf` must not be `null`");
        }
        if (offset == null) {
            throw new IllegalArgumentException("`offset` must not be `null`");
        }
        this.previousBitFieldType = bft;
        this.commands.addAll(List.of("INCRBY", bft.toString(), offset.toString(), Long.toString(value)));
        return this;
    }

    /**
     * Adds a new {@code INCRBY} subcommand using the field type of the previous command.
     *
     * @param offset bitfield offset
     * @param value the value
     * @return a new {@code INCRBY} subcommand for the given {@code bitFieldType}, {@code offset} and {@code value}.
     * @throws IllegalStateException if no previous field type was found
     */
    public BitFieldArgs incrBy(int offset, long value) {

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass a valid BitFieldType (e.g. BitFieldArgs.BitFieldType.unsignedIn8())
  2. Default the type when the lookup returns null
  3. Null-check before calling incrBy()

Example fix

// before
args.incrBy(typeByName.get("counter"), offset, 1); // get may return null
// after
BitFieldArgs.BitFieldType type = typeByName.get("counter");
if (type == null) { type = BitFieldArgs.BitFieldType.unsignedIn8(); }
args.incrBy(type, offset, 1);
Defensive patterns

Strategy: type-guard

Validate before calling

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

Type guard

static boolean canIncrBy(BitFieldArgs.BitFieldType t, BitFieldArgs.Offset o) { return t != null && o != null; }

Try / catch

try { args.incrBy(bft, offset, delta); } catch (IllegalArgumentException e) { log.error("incrBy rejected: " + e.getMessage()); }

Prevention

When it happens

Trigger: args.incrBy(null, offset, delta), typically from a null field type resolved from a lookup or an uninitialized variable.

Common situations: Field-type map miss; config missing a type name; code path where the previous field type was assumed non-null.

Related errors


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