{"record":{"id":"ad7dac3ca232574c","repo":"apache/druid","slug":"empty-list-of-intervals","errorCode":null,"errorMessage":"Empty list of intervals","messagePattern":"Empty list of intervals","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/java/util/common/JodaUtils.java","lineNumber":181,"sourceCode":"      throw new IAE(\"Adjacent intervals are not sorted [%s,%s]\", previous, current);\n    }\n  }\n\n  public static Interval umbrellaInterval(Iterable<Interval> intervals)\n  {\n    boolean emptyIntervals = true;\n    DateTimeComparator dateTimeComp = DateTimeComparator.getInstance();\n    DateTime minStart = new DateTime(Long.MAX_VALUE, ISOChronology.getInstanceUTC());\n    DateTime maxEnd = new DateTime(Long.MIN_VALUE, ISOChronology.getInstanceUTC());\n\n    for (Interval interval : intervals) {\n      emptyIntervals = false;\n      minStart = Collections.min(ImmutableList.of(minStart, interval.getStart()), dateTimeComp);\n      maxEnd = Collections.max(ImmutableList.of(maxEnd, interval.getEnd()), dateTimeComp);\n    }\n\n    if (emptyIntervals) {\n      throw new IllegalArgumentException(\"Empty list of intervals\");\n    }\n    return new Interval(minStart, maxEnd);\n  }\n\n  public static DateTime minDateTime(DateTime... times)\n  {\n    if (times == null) {\n      return null;\n    }\n\n    switch (times.length) {\n      case 0:\n        return null;\n      case 1:\n        return times[0];\n      default:\n        DateTime min = times[0];\n        for (int i = 1; i < times.length; ++i) {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/java/util/common/JodaUtils.java#L163-L199","documentation":"JodaUtils.umbrellaInterval computes the smallest interval covering all given intervals; it throws IllegalArgumentException ('Empty list of intervals') when the iterable yields no elements, because no umbrella interval can exist for an empty set. Note this uses plain IllegalArgumentException, not IAE formatting, and cannot be avoided by passing default values.","triggerScenarios":"Calling umbrellaInterval(Collections.emptyList()) or with a collection filtered down to nothing (e.g. all intervals removed by a null/validity filter before the call).","commonSituations":"Computing the time range of a datasource or task run whose interval list came back empty (no segments ingested yet, fully filtered results); aggregating intervals across shards where some shards had none.","solutions":["Check the collection is non-empty before calling: if (!intervals.iterator().hasNext()) return null / a default interval","Provide a sensible fallback interval (e.g. Universal interval 1970/2100) when the list can legitimately be empty","Fix the upstream query/filter that unexpectedly produced zero intervals"],"exampleFix":"// before\nInterval umbrella = JodaUtils.umbrellaInterval(intervals); // throws when empty\n// after\nInterval umbrella = intervals.isEmpty() ? null : JodaUtils.umbrellaInterval(intervals);","handlingStrategy":"validation","validationCode":"if (intervals == null || intervals.isEmpty()) {\n  return null; // or a default umbrella interval\n}","typeGuard":"static Interval safeUmbrella(List<Interval> intervals, Interval fallback) {\n  return intervals.isEmpty() ? fallback : JodaUtils.umbrellaInterval(intervals);\n}","tryCatchPattern":"try {\n  return JodaUtils.umbrellaInterval(intervals);\n} catch (IllegalArgumentException e) {\n  log.warn(\"No intervals to umbrella; using full range\");\n  return new Interval(0, Long.MAX_VALUE);\n}","preventionTips":["Check for empty input before computing an umbrella interval","Define a documented fallback range for the empty case in your domain","Ensure upstream filters don't silently empty the interval collection"],"tags":["intervals","empty-collection","joda-time"],"backgroundTag":"empty-required-field","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}