quarkusio/quarkus · error · IllegalArgumentException

`overflowType` must not be `null`

Error message

`overflowType` must not be `null`

What it means

BitFieldArgs.overflow(OverflowType) builds the BITFIELD OVERFLOW sub-command and requires an explicit overflow type (WRAP, SAT, or FAIL). It throws this IllegalArgumentException when overflowType is null, preventing an OVERFLOW command with a missing argument from being sent to Redis.

Source

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

     * Adds a new {@code INCRBY} subcommand using offset {@code 0}.
     *
     * @param bitFieldType the bit field type, must not be {@code null}.
     * @param value the value
     * @return the current {@code BitFieldArgs}
     */
    public BitFieldArgs incrBy(BitFieldType bitFieldType, long value) {
        return incrBy(bitFieldType, 0, value);
    }

    /**
     * Adds a new {@code OVERFLOW} subcommand.
     *
     * @param overflowType type of overflow, must not be {@code null}.
     * @return the current {@code BitFieldArgs}
     */
    public BitFieldArgs overflow(OverflowType overflowType) {
        if (overflowType == null) {
            throw new IllegalArgumentException("`overflowType` must not be `null`");
        }
        this.commands.addAll(List.of("OVERFLOW", overflowType.name()));
        return this;
    }

    /**
     * Creates a new signed {@link BitFieldType} for the given number of {@code bits}.
     * Redis allows up to {@code 64} bits for unsigned integers.
     *
     * @param bits number of bits to define the integer type width.
     * @return the {@link BitFieldType}.
     */
    public static BitFieldType signed(int bits) {
        return new BitFieldType(true, bits);
    }

    /**
     * Creates a new unsigned {@link BitFieldType} for the given number of {@code bits}. Redis allows up to {@code 63} bits for

View on GitHub (pinned to e1c734241f)

Solutions

  1. Pass an explicit OverflowType: OverflowType.WRAP, OverflowType.SAT, or OverflowType.FAIL.
  2. If the type comes from a string, normalize case and use OverflowType.valueOf properly, with a default fallback.
  3. Initialize the OverflowType variable before calling overflow().

Example fix

// before
String s = config.getOverflow(); // "WRAP" or unset
args.overflow(s == null ? null : OverflowType.valueOf(s)); // throws when unset
// after
OverflowType t = config.getOverflow() == null ? OverflowType.WRAP : OverflowType.valueOf(config.getOverflow());
args.overflow(t);
Defensive patterns

Strategy: validation

Validate before calling

if (overflowType == null) {
    overflowType = io.quarkus.redis.datasource.bitmap.BitFieldArgs.OverflowType.WRAP; // sane default
}
args.overflow(overflowType);

Type guard

boolean isValidOverflow(BitFieldArgs.OverflowType t) { return t == BitFieldArgs.OverflowType.WRAP || t == BitFieldArgs.OverflowType.SAT || t == BitFieldArgs.OverflowType.FAIL; }

Try / catch

try { args.overflow(type); } catch (IllegalArgumentException e) { if (e.getMessage().contains("overflowType")) { args.overflow(BitFieldArgs.OverflowType.WRAP); } else { throw e; } }

Prevention

When it happens

Trigger: Calling bitFieldArgs.overflow(null), typically because the OverflowType came from an uninitialized variable, a lookup that missed (e.g. Enum.valueOf on an unknown string wrapped in try/catch returning null), or user/config input that was not mapped to an enum.

Common situations: Mapping a config string like "wrap" to OverflowType incorrectly (wrong case) so the lookup yields null; copying example code and dropping the enum argument; conditional selection of overflow policy where the else branch leaves it null.

Related errors


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