apache/druid · error · IAE

GranularitySpec's intervals cannot be empty for replace.

Error message

GranularitySpec's intervals cannot be empty for replace.

What it means

When constructing an IndexTask whose ioConfig implies IngestionMode.REPLACE, the constructor requires that GranularitySpec.inputIntervals is non-empty: a replace must know exactly which intervals it is overwriting so it can unpublish/overwrite those segments. An empty interval set is rejected with this IAE at task-creation time.

Source

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

    private final IndexTuningConfig tuningConfig;

    @JsonCreator
    public IndexIngestionSpec(
        @JsonProperty("dataSchema") DataSchema dataSchema,
        @JsonProperty("ioConfig") IndexIOConfig ioConfig,
        @JsonProperty("tuningConfig") IndexTuningConfig tuningConfig
    )
    {
      super(dataSchema, ioConfig, tuningConfig);

      InvalidInput.notNull(ioConfig.getInputSource(), "inputSource");

      IngestionMode ingestionMode = AbstractTask.computeBatchIngestionMode(ioConfig);

      if (ingestionMode == IngestionMode.REPLACE && dataSchema.getGranularitySpec()
                                                              .inputIntervals()
                                                              .isEmpty()) {
        throw new IAE("GranularitySpec's intervals cannot be empty for replace.");
      }

      if (ioConfig.getInputSource().needsFormat()) {
        InvalidInput.notNull(ioConfig.getInputFormat(), "inputFormat");
      }

      this.dataSchema = dataSchema;
      this.ioConfig = ioConfig;
      this.tuningConfig = tuningConfig == null ? new IndexTuningConfig() : tuningConfig;
    }

    @Override
    @JsonProperty("dataSchema")
    public DataSchema getDataSchema()
    {
      return dataSchema;
    }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Add explicit "intervals" to granularitySpec covering the data being replaced
  2. If the intent is append, set ioConfig type to "index" (append) instead of "replace"
  3. Compute intervals from input data before submitting the task and inject them into the spec
  4. Validate the spec (replace requires non-empty intervals) before submission

Example fix

// before
"ioConfig": { "type": "replace" },
"granularitySpec": { "type": "uniform", "segmentGranularity": "day" } // no intervals
// after
"ioConfig": { "type": "replace" },
"granularitySpec": { "type": "uniform", "segmentGranularity": "day", "intervals": ["2022-01-01/2022-01-31"] }
Defensive patterns

Strategy: validation

Validate before calling

if ("replace".equals(ioConfig.getType())
    && granularitySpec.inputIntervals().isEmpty()) {
  throw new IllegalArgumentException("Replace mode requires non-empty intervals in granularitySpec");
}

Type guard

boolean replaceReady(IndexIOConfig io, GranularitySpec gs) {
  return !IngestionMode.REPLACE.equals(AbstractTask.computeBatchIngestionMode(io))
      || !gs.inputIntervals().isEmpty();
}

Try / catch

try {
  IndexTask task = new IndexTask(id, group, resource, cloneTaskId, schema, mapper, auth, context);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("intervals cannot be empty for replace")) {
    schema = schema.withGranularitySpec(gs.withIntervals(computedIntervals));
    task = rebuild(schema);
  } else throw e;
}

Prevention

When it happens

Trigger: Submitting an index (batch) task with ioConfig type "replace" (or tuning/context making ingestionMode REPLACE) while granularitySpec has no explicit intervals — e.g., omitting "intervals" in granularitySpec, which is allowed for append but not replace.

Common situations: Converting an append task spec to replace by only changing ioConfig type; generating specs from templates that omit intervals; SQL/JSON tooling that drops null intervals; users unfamiliar with the replace-mode requirement.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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