{"record":{"id":"c9f271d6eae7d177","repo":"quickwit-oss/tantivy","slug":"unexpected-type-this-should-not-happen","errorCode":null,"errorMessage":"unexpected type {:?}. This should not happen","messagePattern":"unexpected type (.+?)\\. This should not happen","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/aggregation/bucket/composite/collector.rs","lineNumber":568,"sourceCode":"                        }\n                        self.sub_level_values.push(InternalValueRepr::new_term(\n                            value,\n                            accessor_idx as u8,\n                            current_level_source.order(),\n                        ));\n                        let still_on_after_key = matches_after_key_type\n                            && current_level_accessors.after_key.equals(value);\n                        self.visit(source_idx + 1, is_on_after_key && still_on_after_key)?;\n                        self.sub_level_values.pop();\n                    }\n                    CompositeAggregationSource::Histogram(source) => {\n                        let float_value = match accessor.column_type {\n                            ColumnType::U64 => value as f64,\n                            ColumnType::I64 => i64::from_u64(value) as f64,\n                            ColumnType::DateTime => i64::from_u64(value) as f64 / 1_000_000.,\n                            ColumnType::F64 => f64::from_u64(value),\n                            _ => {\n                                panic!(\n                                    \"unexpected type {:?}. This should not happen\",\n                                    accessor.column_type\n                                )\n                            }\n                        };\n                        let bucket_index = (float_value / source.interval).floor() as i64;\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,","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/aggregation/bucket/composite/collector.rs#L550-L586","documentation":"In the composite aggregation's histogram source, the value-to-float conversion only handles U64, I64, DateTime and F64 column types. Any other type (Str, Bytes, Bool, IpAddr) reaching visit is an internal bug — the source was expected to be a numeric fast field — so it panics with 'unexpected type ... This should not happen'.","triggerScenarios":"Visiting a histogram composite source whose accessor.column_type is not one of U64/I64/DateTime/F64 — e.g. the field resolved to a Str/Bytes/Bool/IpAddr fast field but was declared as a histogram (numeric) source.","commonSituations":"Field type mismatch between schema and aggregation request (requesting a histogram over a text/keyword field); schema migration changed a numeric field to keyword; a bug in accessor type resolution passing the wrong accessor.","solutions":["Ensure the histogram source field is a numeric or date fast field in the schema (u64/i64/f64/date).","Validate the aggregation request against the schema at query build time and reject non-numeric histogram sources.","If the schema looks correct, this is an internal accessor-resolution bug — report it with the schema and query."],"exampleFix":"// before\nCompositeAggregationSource::Histogram(h)\n// after — validate before building the collector\nmatch schema.get_field(name).map(|f| schema.get_field_entry(f).field_type()) {\n    Some(t) if t.is_numeric() || matches!(t, FieldType::Date(_)) => {},\n    _ => return Err(InvalidArgument(\"histogram source requires numeric/date field\")),\n}","handlingStrategy":"validation","validationCode":"match accessor.column_type {\n    ColumnType::U64 | ColumnType::I64 | ColumnType::F64 | ColumnType::DateTime => Ok(()),\n    other => Err(format!(\"histogram requires numeric/date, got {:?}\", other)),\n}","typeGuard":"fn is_numeric_or_date(t: &ColumnType) -> bool {\n    matches!(t, ColumnType::U64 | ColumnType::I64 | ColumnType::F64 | ColumnType::DateTime)\n}","tryCatchPattern":null,"preventionTips":["Validate schema field type matches the aggregation source kind before running the query","Keep histogram sources on numeric/date fast fields","Re-validate mappings after any schema change"],"tags":["panic","aggregation","composite","histogram","type-mismatch"],"backgroundTag":"unexpected-field-type-aggregation","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"}