apache/cassandra · error · InvalidRequestException

Cannot set '" + field + "' to value outside the range…

Error message

Cannot set '" + field + "' to value outside the range (0..1]"

What it means

checkChance validates a float field representing a probability/sampling chance, defaulting to 1.0f when unset. Only values in the half-open interval (0..1] are legal; 0, negatives, and values > 1 throw this InvalidRequestException.

Solutions

  1. Set the field to a value greater than 0 and at most 1 (e.g. 0.5)
  2. Use 1.0 to sample everything, or omit the column for the default of 1.0
  3. Convert percentages to fractions before writing (50% -> 0.5)

Example fix

// before
UPDATE system.accord_debug SET sample_chance = 50;
// after
UPDATE system.accord_debug SET sample_chance = 0.5; // fraction in (0..1], not a percentage
Defensive patterns

Strategy: validation

Validate before calling

if (chance != null && !(chance > 0f && chance <= 1f)) throw new IllegalArgumentException(field + " must be in (0..1]");

Type guard

boolean isValidChance(Float v) { return v == null || (v > 0f && v <= 1f); }

Try / catch

try {
    session.execute(update);
} catch (InvalidRequestException e) {
    if (e.getMessage().contains("outside the range (0..1]")) {
        // resend with chance clamped into (0..1] or omitted for the 1.0 default
    }
}

Prevention

When it happens

Trigger: Setting a chance/probability column on an Accord debug virtual table to 0, a negative number, or any value greater than 1.0 (e.g. SET sample_chance = 0 or = 1.5).

Common situations: Trying to disable sampling by setting chance to 0 (not permitted here — use a different toggle if available); entering a percentage like 50 instead of the fraction 0.5; locale/typo issues producing out-of-range numbers.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/d6ede44457194060. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/db/virtual/AccordDebugKeyspace.java:2508

    private static int checkNonNegative(Object value, String field, int ifNull)
    {
        if (value == null)
            return ifNull;

        int v = (Integer)value;
        if (v < 0)
            throw new InvalidRequestException("Cannot set '" + field + "' to negative value");
        return v;
    }

    private static float checkChance(Object value, String field)
    {
        if (value == null)
            return 1.0f;

        float v = (Float)value;
        if (v <= 0 || v > 1.0f)
            throw new InvalidRequestException("Cannot set '" + field + "' to value outside the range (0..1]");
        return v;
    }

    private static <T extends Enum<T>> Set<String> toStrings(TinyEnumSet<T> set, IntFunction<T> lookup)
    {
        ImmutableSet.Builder<String> builder = ImmutableSet.builder();
        for (T t : set.iterable(lookup))
            builder.add(t.name());
        return builder.build();
    }

    private static AccordTracing tracing()
    {
        return ((AccordAgent)AccordService.unsafeInstance().agent()).tracing();
    }

    private static <E extends Enum<E>> E tryParse(Object input, boolean toUpperCase, Class<E> clazz, Function<String, E> valueOf)
    {

View on GitHub (pinned to 88fd0f6a0e)