influxdata/influxdb · warning

expected bucket id, got TS range

Error message

expected bucket id, got TS range

What it means

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.

Solutions

  1. Call expect_ts_range() instead when the template part produces ranges
  2. Add bucketBy to the template part so Bucket values are produced
  3. Correct the test's expected-value construction to match the template kind

Example fix

// before
let (id, num) = got_val.expect_bucket();
// after
let (begin, end) = got_val.expect_ts_range(); // template part is a time range, not bucketed
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

When it happens

Trigger: 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.

Common situations: Property tests misconfigured: template uses plain time-range parts while assertions assume bucketBy; copy-pasted assertions between range and bucket test blocks.

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


AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19). Data as JSON: /api/errors/ebfaf2b8f8edeed2. Report an issue: GitHub.

Appendix: source

Thrown at core/partition/src/lib.rs:1536

            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,
        ) {
            let mut batch = MutableBatch::new();

View on GitHub (pinned to 06200ef96b)