{"record":{"id":"4b28d82b58b074ea","repo":"quickwit-oss/tantivy","slug":"interval-not-precomputed-for-date-histogram-source","errorCode":null,"errorMessage":"interval not precomputed for date histogram source","messagePattern":"interval not precomputed for date histogram source","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/aggregation/bucket/composite/collector.rs","lineNumber":618,"sourceCode":"                                    accessor.column_type\n                                )\n                            }\n                        };\n                        let bucket_index = match accessor.date_histogram_interval {\n                            PrecomputedDateInterval::FixedNanoseconds(fixed_interval_ns) => {\n                                (value_ns / fixed_interval_ns) * fixed_interval_ns\n                            }\n                            PrecomputedDateInterval::Calendar(CalendarInterval::Year) => {\n                                calendar_interval::try_year_bucket(value_ns)?\n                            }\n                            PrecomputedDateInterval::Calendar(CalendarInterval::Month) => {\n                                calendar_interval::try_month_bucket(value_ns)?\n                            }\n                            PrecomputedDateInterval::Calendar(CalendarInterval::Week) => {\n                                calendar_interval::week_bucket(value_ns)\n                            }\n                            PrecomputedDateInterval::NotApplicable => {\n                                panic!(\"interval not precomputed for date histogram source\")\n                            }\n                        };\n                        let bucket_value = i64::to_u64(bucket_index);\n                        if is_on_after_key {\n                            let should_skip = match current_level_source.order() {\n                                Order::Asc => current_level_accessors.after_key.gt(bucket_value),\n                                Order::Desc => current_level_accessors.after_key.lt(bucket_value),\n                            };\n                            if should_skip {\n                                continue;\n                            }\n                        }\n                        self.sub_level_values.push(InternalValueRepr::new_histogram(\n                            bucket_value,\n                            current_level_source.order(),\n                        ));\n                        let still_on_after_key =\n                            current_level_accessors.after_key.equals(bucket_value);","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/aggregation/bucket/composite/collector.rs#L600-L636","documentation":"Date-interval precomputation for a composite date_histogram source failed to produce an applicable interval: PrecomputedDateInterval::NotApplicable reached the bucketing code. Calendar intervals that need month-aware bucketing must be precomputed; hitting the NotApplicable branch is an internal invariant violation.","triggerScenarios":"Visiting a date_histogram source where the precomputed interval is PrecomputedDateInterval::NotApplicable but the code requires a bucket index (e.g. calendar interval like Month/Quarter/Year that was never precomputed), typically due to a bug in interval preparation from the aggregation request.","commonSituations":"Using calendar_interval values (month/quarter/year) that failed the precompute step; custom or deserialized aggregation requests that skipped interval precomputation; internal refactor leaving a NotApplicable value on a path that requires an interval.","solutions":["Ensure the aggregation request's date_histogram interval is validated and precomputed (via the normal CompositeAggregation request builder) before collection.","If building requests manually/deserialized, run the standard interval precomputation logic instead of bypassing it.","Report as a bug with the exact date_histogram interval used; NotApplicable should never reach visit for a required interval."],"exampleFix":"// before\nlet interval = PrecomputedDateInterval::NotApplicable;\n// after\nlet interval = PrecomputedDateInterval::Calendar(CalendarInterval::Month); // precomputed from request\n// or guard:\nif matches!(interval, PrecomputedDateInterval::NotApplicable) {\n    return Err(TantivyError::InvalidArgument(\"date_histogram interval missing\".into()));\n}","handlingStrategy":"validation","validationCode":"if matches!(precomputed, PrecomputedDateInterval::NotApplicable)\n    && request_requires_interval {\n    return Err(InvalidArgument(\"date_histogram interval not precomputed\"));\n}","typeGuard":"fn interval_ready(p: &PrecomputedDateInterval) -> bool {\n    !matches!(p, PrecomputedDateInterval::NotApplicable)\n}","tryCatchPattern":null,"preventionTips":["Always build date_histogram requests through the standard precomputation path","Validate calendar intervals (month/quarter/year) are precomputed before collection","Report NotApplicable-on-required-path as a library bug"],"tags":["panic","aggregation","composite","date-histogram","invariant-violation"],"backgroundTag":"missing-interval-precompute","analyzedSha":"b5d8deb80c26924e6b007a5b1a7630f35ca64de4","analyzedAt":"2026-09-05T13:20:51.521Z","contentChangedAt":"2026-09-05T13:20:51.521Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}