apache/druid · error · org.apache.druid.java.util.common.IAE

Illegal probability[%s], must be strictly between 0 and 1

Error message

Illegal probability[%s], must be strictly between 0 and 1

What it means

The QuantilesPostAggregator constructor validates each probability in the list is strictly between 0 and 1, throwing IllegalArgumentException for the first invalid one. Quantiles are undefined at 0 or 1, so the entire probability list must be within the open interval.

Source

Thrown at extensions-core/histogram/src/main/java/org/apache/druid/query/aggregation/histogram/QuantilesPostAggregator.java:57

@JsonTypeName("quantiles")
public class QuantilesPostAggregator extends ApproximateHistogramPostAggregator
{
  private final float[] probabilities;

  @JsonCreator
  public QuantilesPostAggregator(
      @JsonProperty("name") String name,
      @JsonProperty("fieldName") String fieldName,
      @JsonProperty("probabilities") float[] probabilities
  )
  {
    super(name, fieldName);
    this.probabilities = probabilities;

    for (float p : probabilities) {
      if (p < 0 || p > 1) {
        throw new IAE("Illegal probability[%s], must be strictly between 0 and 1", p);
      }
    }
  }

  @Override
  public Comparator getComparator()
  {
    throw new UnsupportedOperationException();
  }

  @Override
  public Set<String> getDependentFields()
  {
    return Sets.newHashSet(fieldName);
  }

  @Override
  public Object compute(Map<String, Object> values)

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Validate/filter the probabilities array to values strictly between 0 and 1 before constructing.
  2. Convert percent values with p/100 and reject 0% and 100% requests (use min/max post-aggs instead for extremes).
  3. Clamp or drop boundary values in upstream configuration loading.

Example fix

// before
{"type": "quantiles", "fieldName": "h", "probabilities": [0.5, 1.0]}
// after
{"type": "quantiles", "fieldName": "h", "probabilities": [0.5, 0.99]}
Defensive patterns

Strategy: validation

Validate before calling

for (float p : probabilities) {
  if (!(p > 0 && p < 1)) {
    throw new IllegalArgumentException("probability must be strictly between 0 and 1, got " + p);
  }
}

Type guard

boolean allValidProbabilities(List<Float> ps) {
  return ps.stream().allMatch(p -> p > 0f && p < 1f);
}

Try / catch

try {
  QuantilesPostAggregator q = new QuantilesPostAggregator(name, fieldName, probabilities);
} catch (IllegalArgumentException e) {
  // filter invalid probabilities and retry
}

Prevention

When it happens

Trigger: Building QuantilesPostAggregator with a probabilities array containing any value <= 0 or >= 1, e.g. [0.25, 0.5, 1.0].

Common situations: Percentile lists converted from percent scale where 0 or 100 slipped through; user-supplied percentile config without validation; generated specs with float rounding pushing a value to exactly 1.0f.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/56e4ff96e23da62d. Report an issue: GitHub.