{"record":{"id":"79c75a61dc9c1ccd","repo":"quickwit-oss/tantivy","slug":"null-must-be-handled-separately","errorCode":null,"errorMessage":"null must be handled separately","messagePattern":"null must be handled separately","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/aggregation/bucket/composite/mod.rs","lineNumber":323,"sourceCode":"            ColumnType::F64 | ColumnType::I64 | ColumnType::U64 => ColumnPaginationOrder::Numeric,\n            ColumnType::IpAddr => ColumnPaginationOrder::IpAddr,\n            ColumnType::DateTime => ColumnPaginationOrder::DateTime,\n            ColumnType::Bytes => panic!(\"unsupported\"),\n        }\n    }\n}\n\nimpl ToTypePaginationOrder for CompositeIntermediateKey {\n    fn column_pagination_order(&self) -> ColumnPaginationOrder {\n        match self {\n            CompositeIntermediateKey::Bool(_) => ColumnPaginationOrder::Bool,\n            CompositeIntermediateKey::Str(_) => ColumnPaginationOrder::Str,\n            CompositeIntermediateKey::F64(_)\n            | CompositeIntermediateKey::I64(_)\n            | CompositeIntermediateKey::U64(_) => ColumnPaginationOrder::Numeric,\n            CompositeIntermediateKey::IpAddr(_) => ColumnPaginationOrder::IpAddr,\n            CompositeIntermediateKey::DateTime(_) => ColumnPaginationOrder::DateTime,\n            CompositeIntermediateKey::Null => panic!(\"null must be handled separately\"),\n        }\n    }\n}\n\nimpl ToTypePaginationOrder for CompositeKey {\n    fn column_pagination_order(&self) -> ColumnPaginationOrder {\n        match self {\n            CompositeKey::Bool(_) => ColumnPaginationOrder::Bool,\n            CompositeKey::Str(_) => ColumnPaginationOrder::Str,\n            CompositeKey::F64(_) | CompositeKey::I64(_) | CompositeKey::U64(_) => {\n                ColumnPaginationOrder::Numeric\n            }\n            CompositeKey::Null => panic!(\"null must be handled separately\"),\n        }\n    }\n}\n\n/// After key is a string that encodes the intermediate composite key as \"<type>:<value>\"","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/aggregation/bucket/composite/mod.rs#L305-L341","documentation":"CompositeIntermediateKey::Null represents a missing value in composite aggregation after-keys. Null ordering must be handled by a separate missing-value branch (missing_order logic), so when converting an intermediate key to a pagination order, Null reaching column_pagination_order panics with 'null must be handled separately'.","triggerScenarios":"Calling column_pagination_order() on a CompositeIntermediateKey::Null — i.e. null after-key / bucket key values flowed into the pagination-order computation instead of being handled by the missing-order precompute path (precompute_missing_after_key).","commonSituations":"Composite aggregation over fields with missing values where after-key pagination includes a null key; custom code consuming CompositeIntermediateKey and calling column_pagination_order on it directly without filtering Null; bug in missing-value ordering propagation.","solutions":["Handle Null keys through the missing_order / precompute_missing_after_key path before computing pagination order.","Filter CompositeIntermediateKey::Null out before calling column_pagination_order.","Report a bug if a Null key legitimately reaches pagination ordering in stock aggregation code."],"exampleFix":"// before\nlet order = key.column_pagination_order(); // panics on Null\n// after\nmatch key {\n    CompositeIntermediateKey::Null => /* use missing_order path */,\n    _ => key.column_pagination_order(),\n}","handlingStrategy":"type-guard","validationCode":"if matches!(key, CompositeIntermediateKey::Null) {\n    return handle_missing_order(missing_order);\n}","typeGuard":"fn is_non_null_key(k: &CompositeIntermediateKey) -> bool {\n    !matches!(k, CompositeIntermediateKey::Null)\n}","tryCatchPattern":null,"preventionTips":["Route null after-keys through the missing_order precompute path","Filter Null keys before calling column_pagination_order","Test composite pagination on fields with missing values"],"tags":["panic","aggregation","composite","null","pagination"],"backgroundTag":"null-key-not-handled","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"}