{"record":{"id":"a4add6984be4a95a","repo":"thanos-io/thanos","slug":"errparsekeyint","errorCode":"ErrParseKeyInt","errorMessage":"failed to parse integer in key","messagePattern":"failed to parse integer in key","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/store/cache/cachekey/cachekey.go","lineNumber":16,"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\n\tStart                   int64","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/cache/cachekey/cachekey.go#L1-L34","documentation":"For subrange cache keys (\"subrange:name:start:end\"), ParseBucketCacheKey parses the 3rd and 4th fields with strconv.ParseInt. If either start or end is not a valid base-10 64-bit integer, ErrParseKeyInt is returned, meaning the key is structurally right but numerically malformed.","triggerScenarios":"ParseBucketCacheKey called with a subrange key whose start or end field is non-numeric or out of int64 range, e.g. \"subrange:obj:abc:def\" or \"subrange:obj:99999999999999999999:200\".","commonSituations":"Corrupted cache entries in memcached/redis; hand-written keys in tooling or tests; truncation of keys by a cache backend with key length limits.","solutions":["Validate that the start/end segments parse as int64 before calling ParseBucketCacheKey and skip invalid entries.","Clear the cache backend of corrupted or truncated keys.","Check whether the cache backend truncates or mangles long keys and raise its limits.","Fix any custom producer emitting non-integer offsets."],"exampleFix":"// before\nck, err := cachekey.ParseBucketCacheKey(key)\n// after\nparts := strings.Split(key, \":\")\nif len(parts) >= 4 {\n    if _, e1 := strconv.ParseInt(parts[2], 10, 64); e1 != nil {\n        return nil, nil // skip bad subrange key\n    }\n}\nck, err := cachekey.ParseBucketCacheKey(key)","handlingStrategy":"validation","validationCode":"parts := strings.Split(key, \":\")\nif len(parts) >= 4 {\n    if _, err := strconv.ParseInt(parts[2], 10, 64); err != nil {\n        return nil, fmt.Errorf(\"bad start %q\", parts[2])\n    }\n    if _, err := strconv.ParseInt(parts[3], 10, 64); err != nil {\n        return nil, fmt.Errorf(\"bad end %q\", parts[3])\n    }\n}","typeGuard":null,"tryCatchPattern":"ck, err := cachekey.ParseBucketCacheKey(key)\nif errors.Is(err, cachekey.ErrParseKeyInt) {\n    logger.Debug(\"corrupted subrange key, skipping\", \"key\", key)\n    continue\n}","preventionTips":["Validate integer segments before parsing cache keys","Watch for cache backends truncating long keys","Reject non-numeric offsets at key-production time","Treat corrupted entries as skippable"],"tags":["go","cache","parsing","integer"],"backgroundTag":"invalid-argument-format","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"}