{"record":{"id":"ebfaf2b8f8edeed2","repo":"influxdata/influxdb","slug":"expected-bucket-id-got-ts-range","errorCode":null,"errorMessage":"expected bucket id, got TS range","messagePattern":"expected bucket id, got TS range","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/partition/src/lib.rs","lineNumber":1536,"sourceCode":"            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()`].\n        #[test]\n        fn prop_reversible_mapping(\n            template in arbitrary_template_parts(),\n            tag_values in arbitrary_tag_value_map(),\n            ts in 0_i64..i64::MAX,\n        ) {\n            let mut batch = MutableBatch::new();","sourceCodeStart":1518,"sourceCodeEnd":1554,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/partition/src/lib.rs#L1518-L1554","documentation":"Test helper expect_bucket panics with this message when the enum holds TSRange instead of Bucket. It mirrors the other variants' narrow-down helpers in the proptests for time partitioning, signaling the test compared a timestamp-range value against bucket expectations.","triggerScenarios":"Calling expect_bucket() on a variant holding ColumnValue::TSRange — the partitioner emitted a timestamp range (non-bucketed template part) but the test expected a bucket id.","commonSituations":"Property tests misconfigured: template uses plain time-range parts while assertions assume bucketBy; copy-pasted assertions between range and bucket test blocks.","solutions":["Call expect_ts_range() instead when the template part produces ranges","Add bucketBy to the template part so Bucket values are produced","Correct the test's expected-value construction to match the template kind"],"exampleFix":"// before\nlet (id, num) = got_val.expect_bucket();\n// after\nlet (begin, end) = got_val.expect_ts_range(); // template part is a time range, not bucketed","handlingStrategy":"type-guard","validationCode":"assert!(matches!(got_val, ColumnValue::Bucket{..}), \"expected Bucket, got {got_val:?}\");","typeGuard":"fn is_bucket(v: &ColumnValue) -> bool { matches!(v, ColumnValue::Bucket{..}) }","tryCatchPattern":null,"preventionTips":["Use expect_ts_range() for range-producing templates","Ensure template parts include bucketBy before bucket assertions","Differentiate test fixtures for range vs bucket scenarios"],"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"}