{"record":{"id":"63c2140ef6841f78","repo":"thanos-io/thanos","slug":"errinvalidbucketcachekeyverb","errorCode":"ErrInvalidBucketCacheKeyVerb","errorMessage":"key has invalid verb","messagePattern":"key has invalid verb","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/store/cache/cachekey/cachekey.go","lineNumber":15,"sourceCode":"// Copyright (c) The Thanos Authors.\n// Licensed under the Apache License 2.0.\n\npackage cachekey\n\nimport (\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/pkg/errors\"\n)\n\nvar (\n\tErrInvalidBucketCacheKeyFormat = errors.New(\"key has invalid format\")\n\tErrInvalidBucketCacheKeyVerb   = errors.New(\"key has invalid verb\")\n\tErrParseKeyInt                 = errors.New(\"failed to parse integer in key\")\n)\n\n// VerbType is the type of operation whose result has been stored in the caching bucket's cache.\ntype VerbType string\n\nconst (\n\tExistsVerb        VerbType = \"exists\"\n\tContentVerb       VerbType = \"content\"\n\tIterVerb          VerbType = \"iter\"\n\tIterRecursiveVerb VerbType = \"iter-recursive\"\n\tAttributesVerb    VerbType = \"attrs\"\n\tSubrangeVerb      VerbType = \"subrange\"\n)\n\ntype BucketCacheKey struct {\n\tVerb                    VerbType\n\tName                    string","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/cache/cachekey/cachekey.go#L1-L33","documentation":"ParseBucketCacheKey requires the first colon-separated field of a cache key to be a known VerbType (e.g. subrange). If the verb is not recognized by IsValidVerb, the key cannot be interpreted and ErrInvalidBucketCacheKeyVerb is returned.","triggerScenarios":"Calling ParseBucketCacheKey with a key whose first segment is not a registered verb, e.g. \"random:name\" (as in the unit test) or \"get:obj\" where \"get\" is not a valid VerbType.","commonSituations":"Forward/backward version mismatch: newer writer introduced a verb an older reader doesn't know; manual cache inspection tools constructing keys; typo'd verb in custom cache implementations.","solutions":["Check the key's verb against cachekey.IsValidVerb before parsing and skip unknown verbs.","Clear/regenerate cache entries produced by an incompatible Thanos version.","Align all store-gateway/query instances to the same version so verb sets match.","Fix the key producer to emit one of the supported verbs (e.g. subrange)."],"exampleFix":"// before\nck, err := cachekey.ParseBucketCacheKey(key)\n// after\nif !cachekey.IsValidVerb(cachekey.VerbType(strings.SplitN(key, \":\", 2)[0])) {\n    return nil, nil // skip unknown-verb cache entry\n}\nck, err := cachekey.ParseBucketCacheKey(key)","handlingStrategy":"validation","validationCode":"verb := cachekey.VerbType(strings.SplitN(key, \":\", 2)[0])\nif !cachekey.IsValidVerb(verb) {\n    return nil, fmt.Errorf(\"unknown verb %q\", verb)\n}","typeGuard":"func hasKnownVerb(key string) bool {\n    parts := strings.SplitN(key, \":\", 2)\n    return len(parts) == 2 && cachekey.IsValidVerb(cachekey.VerbType(parts[0]))\n}","tryCatchPattern":"ck, err := cachekey.ParseBucketCacheKey(key)\nif errors.Is(err, cachekey.ErrInvalidBucketCacheKeyVerb) {\n    logger.Debug(\"unknown cache key verb, skipping\", \"key\", key)\n    continue\n}","preventionTips":["Gate cache reads with IsValidVerb checks","Keep all instances on the same version when sharing a cache","Only produce keys via cachekey package helpers","Log-and-skip unknown verbs instead of failing"],"tags":["go","cache","key-format","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}