{"record":{"id":"046c5fb1dacba326","repo":"influxdata/influxdb","slug":"expected-bucket-id-got-string","errorCode":null,"errorMessage":"expected bucket id, got string","messagePattern":"expected bucket id, got string","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/partition/src/lib.rs","lineNumber":1535,"sourceCode":"        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()`].\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        ) {","sourceCodeStart":1517,"sourceCodeEnd":1553,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/partition/src/lib.rs#L1517-L1553","documentation":"Test helper expect_bucket panics with this message when the enum holds the String variant instead of Bucket. It is a proptest narrowing helper verifying bucketed time partitioning; this panic means a string-formatted column value was produced where a bucket id was expected.","triggerScenarios":"Calling expect_bucket() on a variant holding ColumnValue::String — e.g. the template part rendered as a plain strftime string rather than being converted to a bucket.","commonSituations":"Property tests where the fixture template produced string keys instead of bucketed values; forgetting that a template without bucketBy renders strings.","solutions":["Ensure the template part under test actually uses bucketing (bucketBy) before calling expect_bucket()","Use expect_ts_range()/string expectations for non-bucketed templates","Fix fixture construction so ColumnValue::Bucket is produced"],"exampleFix":"// before\nlet (id, num) = got_val.expect_bucket();\n// after\nmatch got_val {\n    ColumnValue::Bucket{..} => { let (id, num) = got_val.expect_bucket(); }\n    ColumnValue::String(_) => { /* string template part — adjust test */ }\n    _ => {}\n}","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":["Only call expect_bucket() when the template part uses bucketing","Assert the variant with matches! before narrowing","Review copy-pasted assertions between range and bucket tests"],"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"}