apache/druid · error · IllegalArgumentException

Interval[%s] is empty, must specify a nonempty interval

Error message

Interval[%s] is empty, must specify a nonempty interval

What it means

CompactionIntervalSpec constructor rejects an Interval whose duration is exactly zero. A zero-length interval selects no segments, so Druid throws IAE at spec-construction/deserialization time rather than launching a pointless compaction task.

Source

Thrown at indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionIntervalSpec.java:54

/**
 * Specifying an interval to compact. A hash of the segment IDs can be optionally provided for segment validation.
 */
public class CompactionIntervalSpec implements CompactionInputSpec
{
  public static final String TYPE = "interval";

  private final Interval interval;
  @Nullable
  private final String sha256OfSortedSegmentIds;

  @JsonCreator
  public CompactionIntervalSpec(
      @JsonProperty("interval") Interval interval,
      @JsonProperty("sha256OfSortedSegmentIds") @Nullable String sha256OfSortedSegmentIds
  )
  {
    if (interval != null && interval.toDurationMillis() == 0) {
      throw new IAE("Interval[%s] is empty, must specify a nonempty interval", interval);
    }
    this.interval = interval;
    this.sha256OfSortedSegmentIds = sha256OfSortedSegmentIds;
  }

  @JsonProperty
  public Interval getInterval()
  {
    return interval;
  }

  @Nullable
  @JsonProperty
  public String getSha256OfSortedSegmentIds()
  {
    return sha256OfSortedSegmentIds;
  }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Widen the interval so end is strictly after start (e.g., "2023-01-01/2024-01-01").
  2. Check upstream code that computes start/end timestamps and guard against equal values before constructing the spec.
  3. If the intent was 'all data', omit the interval or use the datasource's full range instead.

Example fix

// before
"interval": "2023-01-01T00:00:00Z/2023-01-01T00:00:00Z"
// after
"interval": "2023-01-01T00:00:00Z/2023-02-01T00:00:00Z"
Defensive patterns

Strategy: validation

Validate before calling

if (interval != null && interval.toDurationMillis() == 0) throw new IllegalArgumentException("interval must be nonempty: " + interval);

Try / catch

try { new CompactionIntervalSpec(interval, hash); } catch (IAE e) { if (e.getMessage().contains("is empty")) { widen interval; } else throw e; }

Prevention

When it happens

Trigger: Deserializing a compaction config where "interval" is like "2023-01-01/2023-01-01"; programmatically computing start==end intervals; passing an empty/null-derived interval built from two identical timestamps.

Common situations: Templates where interval start/end are filled from the same variable; time-boundary computation returning equal boundaries for empty data ranges; typos in ISO interval strings.

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/938217ea10939539. Report an issue: GitHub.