{"record":{"id":"f3c646f75db216bc","repo":"vitessio/vitess","slug":"label-v-is-not-one-of-v","errorCode":null,"errorMessage":"label %v is not one of %v","messagePattern":"label (.+?) is not one of (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/stats/multidimensional.go","lineNumber":53,"sourceCode":"\tfor i, lab := range mt.Labels() {\n\t\tif lab == dimension {\n\t\t\treturn wrappedCountTracker{\n\t\t\t\tf: func() map[string]int64 {\n\t\t\t\t\tresult := make(map[string]int64)\n\t\t\t\t\tfor k, v := range mt.Counts() {\n\t\t\t\t\t\tif k == \"All\" {\n\t\t\t\t\t\t\tresult[k] = v\n\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t}\n\t\t\t\t\t\tresult[strings.Split(k, \".\")[i]] += v\n\t\t\t\t\t}\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\tpanic(fmt.Sprintf(\"label %v is not one of %v\", dimension, mt.Labels()))\n}\n","sourceCodeStart":35,"sourceCodeEnd":55,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/stats/multidimensional.go#L35-L55","documentation":"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.","triggerScenarios":"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\".","commonSituations":"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.","solutions":["Pass a dimension value that exactly matches one of the strings returned by mt.Labels().","Update the MultiTimings creation site to declare the new label if the extra dimension is legitimate.","Normalize the requested value (trim/case) before lookup, and check membership against Labels() to fail with a clear error instead of the panic."],"exampleFix":"// before\nlabel := \"Keyspace\"\nc := mt.CounterForDimension(label) // panics if not declared\n// after\nfor _, l := range mt.Labels() {\n    if l == label {\n        c := mt.CounterForDimension(label)\n        _ = c\n        break\n    }\n}","handlingStrategy":"validation","validationCode":"allowed := mt.Labels()\nfound := slices.Contains(allowed, dimension)\nif !found {\n    return fmt.Errorf(\"dimension %q not declared; allowed: %v\", dimension, allowed)\n}\nc := mt.CounterForDimension(dimension)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only look up dimensions returned by Labels(); source them from the same constant list used at construction.","Normalize casing/whitespace of dimension values before lookup.","Re-run lookups after any change to the MultiTimings label set."],"tags":["go","stats","panic","invalid-label","multidimensional"],"backgroundTag":"unknown-label-value","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}