thanos-io/thanos · warning
ErrParseKeyInt
ErrParseKeyInt
Error message
failed to parse integer in key
What it means
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.
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.
Example fix
// before
ck, err := cachekey.ParseBucketCacheKey(key)
// after
parts := strings.Split(key, ":")
if len(parts) >= 4 {
if _, e1 := strconv.ParseInt(parts[2], 10, 64); e1 != nil {
return nil, nil // skip bad subrange key
}
}
ck, err := cachekey.ParseBucketCacheKey(key) Defensive patterns
Strategy: validation
Validate before calling
parts := strings.Split(key, ":")
if len(parts) >= 4 {
if _, err := strconv.ParseInt(parts[2], 10, 64); err != nil {
return nil, fmt.Errorf("bad start %q", parts[2])
}
if _, err := strconv.ParseInt(parts[3], 10, 64); err != nil {
return nil, fmt.Errorf("bad end %q", parts[3])
}
} Try / catch
ck, err := cachekey.ParseBucketCacheKey(key)
if errors.Is(err, cachekey.ErrParseKeyInt) {
logger.Debug("corrupted subrange key, skipping", "key", key)
continue
} Prevention
- 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
When it happens
Trigger: 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".
Common situations: Corrupted cache entries in memcached/redis; hand-written keys in tooling or tests; truncation of keys by a cache backend with key length limits.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- ErrInvalidBucketCacheKeyFormat
- ErrInvalidBucketCacheKeyVerb
- errObjNotFound
- failed to get object attributes
- fetching range [ , ]: caching key for offset not found
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/a4add6984be4a95a.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/store/cache/cachekey/cachekey.go:16
// Copyright (c) The Thanos Authors.
// Licensed under the Apache License 2.0.
package cachekey
import (
"strconv"
"strings"
"github.com/pkg/errors"
)
var (
ErrInvalidBucketCacheKeyFormat = errors.New("key has invalid format")
ErrInvalidBucketCacheKeyVerb = errors.New("key has invalid verb")
ErrParseKeyInt = errors.New("failed to parse integer in key")
)
// VerbType is the type of operation whose result has been stored in the caching bucket's cache.
type VerbType string
const (
ExistsVerb VerbType = "exists"
ContentVerb VerbType = "content"
IterVerb VerbType = "iter"
IterRecursiveVerb VerbType = "iter-recursive"
AttributesVerb VerbType = "attrs"
SubrangeVerb VerbType = "subrange"
)
type BucketCacheKey struct {
Verb VerbType
Name string
Start int64View on GitHub (pinned to 35b8b99117)