apache/druid · error · IllegalArgumentException
null/empty intervals
Error message
null/empty intervals
What it means
IndexerSQLMetadataStorageCoordinator.retrieveUsedSegmentsForIntervals requires a non-null, non-empty interval list before querying the metadata store. Null or empty input throws IAE('null/empty intervals') because the SQL query built from the intervals would be meaningless.
Source
Thrown at server/src/main/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinator.java:194
DateTime maxUpdatedTime,
int maxResultSize,
int maxSegmentsToScan
)
{
return inReadOnlyTransaction(
sql -> sql.retrieveSomeUnusedSegmentIntervals(maxUpdatedTime, maxResultSize, maxSegmentsToScan)
);
}
@Override
public Set<DataSegment> retrieveUsedSegmentsForIntervals(
final String dataSource,
final List<Interval> intervals,
final Segments visibility
)
{
if (intervals == null || intervals.isEmpty()) {
throw new IAE("null/empty intervals");
}
return doRetrieveUsedSegments(dataSource, intervals, visibility);
}
@Override
public Set<DataSegment> retrieveAllUsedSegments(String dataSource, Segments visibility)
{
return doRetrieveUsedSegments(dataSource, Collections.emptyList(), visibility);
}
/**
* @param intervals empty list means unrestricted interval.
*/
private Set<DataSegment> doRetrieveUsedSegments(
final String dataSource,
final List<Interval> intervals,
final Segments visibility
)View on GitHub (pinned to 9b90983fd2)
Solutions
- Check intervals for null/empty before calling and short-circuit to return an empty segment set
- Fix the upstream interval computation so it produces at least one Interval
- If 'all segments' is intended, use retrieveAllUsedSegments instead
Example fix
// before
Set<DataSegment> segments = coordinator.retrieveUsedSegmentsForIntervals(ds, intervals, Segments.ONLY_VISIBLE);
// after
Set<DataSegment> segments = (intervals == null || intervals.isEmpty())
? Collections.emptySet()
: coordinator.retrieveUsedSegmentsForIntervals(ds, intervals, Segments.ONLY_VISIBLE); Defensive patterns
Strategy: validation
Validate before calling
if (intervals == null || intervals.isEmpty()) { return Collections.emptySet(); } Type guard
boolean hasIntervals = intervals != null && !intervals.isEmpty();
Try / catch
try { segments = coordinator.retrieveUsedSegmentsForIntervals(ds, intervals, visibility); } catch (IllegalArgumentException e) { if (e.getMessage().contains("null/empty intervals")) { segments = Collections.emptySet(); } else { throw e; } } Prevention
- Validate interval lists before metadata-store queries
- Treat empty input as an empty result early in the calling code
- Use retrieveAllUsedSegments when the intent is to fetch everything
When it happens
Trigger: Calling retrieveUsedSegmentsForIntervals(dataSource, null, visibility) or with an empty List<Interval>, usually when a caller computed segments intervals from an empty query/timeline result.
Common situations: Batch task or coordinator code passing an empty interval list derived from no input shards; API callers requesting used segments without specifying any intervals.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- announceHistoricalSegments failed with null metadata, should
- Segments to drop must all be part of the same datasource
- maxStringBytes must be greater than 0
- maxStringBytes must be greater than 0
- Unknown operation[%s], known operations[%s]
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/407519748a23cb58.
Report an issue: GitHub.