vitessio/vitess · error

label %v is not one of %v

Error message

label %v is not one of %v

What it means

MultiTimings/MultiCounter look up the per-dimension counter by exact label value; if the requested dimension value was never declared as one of the component's labels, there is no counter to return, so the library panics with the offending label and the allowed set.

Source

Thrown at go/stats/multidimensional.go:53

	for i, lab := range mt.Labels() {
		if lab == dimension {
			return wrappedCountTracker{
				f: func() map[string]int64 {
					result := make(map[string]int64)
					for k, v := range mt.Counts() {
						if k == "All" {
							result[k] = v
							continue
						}
						result[strings.Split(k, ".")[i]] += v
					}
					return result
				},
			}
		}
	}

	panic(fmt.Sprintf("label %v is not one of %v", dimension, mt.Labels()))
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Pass a dimension value that exactly matches one of the strings returned by mt.Labels().
  2. Update the MultiTimings creation site to declare the new label if the extra dimension is legitimate.
  3. Normalize the requested value (trim/case) before lookup, and check membership against Labels() to fail with a clear error instead of the panic.

Example fix

// before
label := "Keyspace"
c := mt.CounterForDimension(label) // panics if not declared
// after
for _, l := range mt.Labels() {
    if l == label {
        c := mt.CounterForDimension(label)
        _ = c
        break
    }
}
Defensive patterns

Strategy: validation

Validate before calling

allowed := mt.Labels()
found := slices.Contains(allowed, dimension)
if !found {
    return fmt.Errorf("dimension %q not declared; allowed: %v", dimension, allowed)
}
c := mt.CounterForDimension(dimension)

Prevention

When it happens

Trigger: Calling mt.CounterForDimension(value) (or a wrapped counter function) with a value not present in the Labels() slice used when the MultiTimings was created, e.g. CounterForDimension("Keyspace") on a MultiTimings initialized with only "Db".

Common situations: Renaming a label value at the creation site but not at the lookup site; config-driven dimension values that expand beyond the declared set; typos/case differences between the declared and requested dimension.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/f3c646f75db216bc. Report an issue: GitHub.