thanos-io/thanos · error
unsupported cache type
Error message
unsupported cache type: %s
What it means
After trying MEMCACHED, IN-MEMORY, GROUPCACHE and REDIS providers, any other config.Type value hits the default branch and yields errors.Errorf("unsupported cache type: %s"). The library throws it because the cache type string must match one of the supported BucketCacheProvider constants.
Solutions
- Set type to one of the supported values: MEMCACHED, IN-MEMORY, GROUPCACHE, REDIS (uppercase)
- Check the error message: it echoes the offending type string for comparison
- Confirm your Thanos version supports the type you want (check BucketCacheProvider constants)
- Compare against examples in Thanos docs/caching_bucket.md
- Note the switch uppercases the type, so a correct-name-but-wrong-spelling is still rejected
Example fix
// before
config:
caches:
chunks:
type: inmemory # not an exact supported constant
// after
config:
caches:
chunks:
type: IN-MEMORY Defensive patterns
Strategy: validation
Validate before calling
var probe struct { Config struct { Caches map[string]struct{ Type string `yaml:"type"` } `yaml:"caches"` } `yaml:"config"` }
if err := yaml.Unmarshal(yamlContent, &probe); err != nil { return err }
for name, c := range probe.Config.Caches {
switch c.Type {
case "MEMCACHED", "IN-MEMORY", "GROUPCACHE", "REDIS":
default:
return fmt.Errorf("cache %q: unsupported type %q", name, c.Type)
}
} Type guard
func supportedCacheType(t string) bool {
switch t {
case "MEMCACHED", "IN-MEMORY", "GROUPCACHE", "REDIS":
return true
}
return false
} Try / catch
cb, err := storecache.NewCachingBucketFromYaml(yamlContent, logger, reg, bucket, router)
if err != nil {
if strings.Contains(err.Error(), "unsupported cache type") {
return fmt.Errorf("use MEMCACHED, IN-MEMORY, GROUPCACHE or REDIS: %w", err)
}
return err
} Prevention
- Type must be exactly MEMCACHED, IN-MEMORY, GROUPCACHE or REDIS (uppercase)
- Check provider constants for your Thanos version before adding a new type
- Copy cache type values only from official Thanos docs/examples
When it happens
Trigger: NewCachingBucketFromYaml given YAML whose cache config 'type' is not exactly one of MEMCACHED, IN-MEMORY, GROUPCACHE, REDIS (matching is case-sensitive via strings.ToUpper on config.Type — a misspelling or unknown provider triggers this).
Common situations: Typos like 'inmemory', 'memcache', or lowercase variants stored oddly, using a provider introduced in a newer Thanos than the one deployed, or copying config from another project (e.g. Cortex) with different type names.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid reload method
- failed to parse template
- failed to execute template
- error while parsing config for request logging
- getting http client config
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/1a53be6ea1ee3cad.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/store/cache/caching_bucket_factory.go:138
if err != nil {
return nil, errors.Wrapf(err, "failed to create inmemory cache")
}
case string(GroupcacheBucketCacheProvider):
const basePath = "/_galaxycache/"
c, err = cache.NewGroupcache(logger, reg, backendConfig, basePath, r, bucket, cfg)
if err != nil {
return nil, errors.Wrap(err, "failed to create groupcache")
}
case string(RedisBucketCacheProvider):
redisCache, err := cacheutil.NewRedisClient(logger, "caching-bucket", backendConfig, reg)
if err != nil {
return nil, errors.Wrapf(err, "failed to create redis client")
}
c = cache.NewRedisCache("caching-bucket", logger, redisCache, reg)
default:
return nil, errors.Errorf("unsupported cache type: %s", config.Type)
}
// Include interactions with cache in the traces.
c = cache.NewTracingCache(c)
cfg.SetCacheImplementation(c)
cb, err := NewCachingBucket(bucket, cfg, logger, reg)
if err != nil {
return nil, err
}
return cb, nil
}
var chunksMatcher = regexp.MustCompile(`^.*/chunks/\d+$`)
func isTSDBChunkFile(name string) bool { return chunksMatcher.MatchString(name) }
View on GitHub (pinned to 35b8b99117)