influxdata/influxdb · warning
expected bucket id, got string
Error message
expected bucket id, got string
What it means
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.
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
Example fix
// before
let (id, num) = got_val.expect_bucket();
// after
match got_val {
ColumnValue::Bucket{..} => { let (id, num) = got_val.expect_bucket(); }
ColumnValue::String(_) => { /* string template part — adjust test */ }
_ => {}
} Defensive patterns
Strategy: type-guard
Validate before calling
assert!(matches!(got_val, ColumnValue::Bucket{..}), "expected Bucket, got {got_val:?}"); Type guard
fn is_bucket(v: &ColumnValue) -> bool { matches!(v, ColumnValue::Bucket{..}) } Prevention
- 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
When it happens
Trigger: 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.
Common situations: Property tests where the fixture template produced string keys instead of bucketed values; forgetting that a template without bucketBy renders strings.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- expected bucket id, got TS range
- expected TS range, got bucket id
- expected datatime column value but got
- expected i64 got
- column id in series key should be valid
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/046c5fb1dacba326.
Report an issue: GitHub.
Appendix: source
Thrown at core/partition/src/lib.rs:1535
fn expect_string(&self) -> &String {
match self {
Self::String(s) => s,
Self::TSRange(_, _) => panic!("expected string, got TS range"),
Self::Bucket(_, _) => panic!("expected string, got bucket id"),
}
}
fn expect_ts_range(&self) -> (DateTime<Utc>, DateTime<Utc>) {
match self {
Self::String(_) => panic!("expected TS range, got string"),
Self::TSRange(b, e) => (*b, *e),
Self::Bucket(_, _) => panic!("expected TS range, got bucket id"),
}
}
fn expect_bucket(&self) -> (u32, u32) {
match self {
Self::String(_) => panic!("expected bucket id, got string"),
Self::TSRange(_, _) => panic!("expected bucket id, got TS range"),
Self::Bucket(id, num_buckets) => (*id, *num_buckets),
}
}
}
proptest! {
/// A property test that asserts a write comprised of an arbitrary
/// subset of [`TEST_TAG_NAME_SET`] with randomised values, that is
/// partitioned using a partitioning template arbitrarily selected from
/// [`TEST_TEMPLATE_PARTS`], can be reversed to the full set of tags
/// and/or hash-bucket IDs via [`build_column_values()`].
#[test]
fn prop_reversible_mapping(
template in arbitrary_template_parts(),
tag_values in arbitrary_tag_value_map(),
ts in 0_i64..i64::MAX,
) {View on GitHub (pinned to 06200ef96b)