{"record":{"id":"6606e5c51eac98aa","repo":"influxdata/influxdb","slug":"expected-ts-range-got-bucket-id","errorCode":null,"errorMessage":"expected TS range, got bucket id","messagePattern":"expected TS range, got bucket id","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/partition/src/lib.rs","lineNumber":1529,"sourceCode":"        String(String),\n        TSRange(DateTime<Utc>, DateTime<Utc>),\n        Bucket(u32, u32),\n    }\n\n    impl ExpectedColumnValue {\n        fn expect_string(&self) -> &String {\n            match self {\n                Self::String(s) => s,\n                Self::TSRange(_, _) => panic!(\"expected string, got TS range\"),\n                Self::Bucket(_, _) => panic!(\"expected string, got bucket id\"),\n            }\n        }\n\n        fn expect_ts_range(&self) -> (DateTime<Utc>, DateTime<Utc>) {\n            match self {\n                Self::String(_) => panic!(\"expected TS range, got string\"),\n                Self::TSRange(b, e) => (*b, *e),\n                Self::Bucket(_, _) => panic!(\"expected TS range, got bucket id\"),\n            }\n        }\n\n        fn expect_bucket(&self) -> (u32, u32) {\n            match self {\n                Self::String(_) => panic!(\"expected bucket id, got string\"),\n                Self::TSRange(_, _) => panic!(\"expected bucket id, got TS range\"),\n                Self::Bucket(id, num_buckets) => (*id, *num_buckets),\n            }\n        }\n    }\n\n    proptest! {\n        /// A property test that asserts a write comprised of an arbitrary\n        /// subset of [`TEST_TAG_NAME_SET`] with randomised values, that is\n        /// partitioned using a partitioning template arbitrarily selected from\n        /// [`TEST_TEMPLATE_PARTS`], can be reversed to the full set of tags\n        /// and/or hash-bucket IDs via [`build_column_values()`].","sourceCodeStart":1511,"sourceCodeEnd":1547,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/partition/src/lib.rs#L1511-L1547","documentation":"A test-only helper expect_ts_range panics when the enum holds the Bucket variant instead of TSRange. It is a narrow-down helper in proptests verifying that bucketed time partitioning produces the expected ColumnValue shapes; hitting this panic means the code produced a bucket where a timestamp range was expected.","triggerScenarios":"Calling expect_ts_range() on a variant holding ColumnValue::Bucket — i.e. the partitioner produced bucket-id output while the test expected a timestamp range (e.g. template part configured with bucketing instead of plain time range).","commonSituations":"Test-authoring mistakes: comparing outputs of a bucketed template against range expectations; mixing bucketBy and range-style expectations in a property test.","solutions":["Match the expectation to the template: call expect_bucket() when the template uses bucketing","Fix the test fixture/template so it produces TSRange output if a range is what should be verified","Inspect ColumnValue construction to see why Bucket was produced instead of TSRange"],"exampleFix":"// before\nlet (b, e) = got_val.expect_ts_range();\n// after\nlet (id, num) = got_val.expect_bucket(); // template uses bucketBy\n// or\nif let ColumnValue::TSRange{..} = got_val { let (b,e) = got_val.expect_ts_range(); }","handlingStrategy":"type-guard","validationCode":"// in tests, check the variant before narrowing\nassert!(matches!(got_val, ColumnValue::TSRange{..}), \"expected TSRange, got {got_val:?}\");","typeGuard":"fn is_ts_range(v: &ColumnValue) -> bool { matches!(v, ColumnValue::TSRange{..}) }","tryCatchPattern":null,"preventionTips":["Match expectations to template kind: bucketBy -> Bucket, time range -> TSRange","Use matches! guards instead of expect_* helpers when variant may vary","Keep fixture templates and assertions in sync"],"tags":["rust","panic","test-helper","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}