thanos-io/thanos · error
parsing config YAML file
Error message
parsing config YAML file
What it means
NewCacheConfig parses a Thanos query-frontend cache configuration YAML into a Cortex cache config. yaml.UnmarshalStrict rejects unknown or malformed fields, and the error is wrapped with 'parsing config YAML file'. It means the cache YAML supplied (e.g. via --query-range.response-cache-config-file) is not a valid cache provider config.
Solutions
- Fix the YAML so it strictly matches CacheProviderConfig: only 'type' and 'config' keys with valid types.
- Validate the YAML against the Thanos documentation example for the chosen cache backend (in-memory, memcached, redis).
- Remove unknown/renamed fields; check for version drift between Thanos releases.
- Test the config parsing locally before deploying.
Example fix
# before
cache:
type: memcached
memcached:
addresses: [localhost:11211]
# after
type: MEMCACHED
config:
addresses: [localhost:11211] Defensive patterns
Strategy: validation
Validate before calling
// validate cache YAML before handing to Thanos
var probe struct {
Type string `yaml:"type"`
Config map[string]interface{} `yaml:"config"`
}
if err := yaml.UnmarshalStrict(data, &probe); err != nil {
return fmt.Errorf("invalid cache config: %w", err)
} Try / catch
cfg, err := queryfrontend.NewCacheConfig(logger, yamlBytes)
if err != nil {
if strings.Contains(err.Error(), "parsing config YAML file") {
return fmt.Errorf("cache config YAML invalid, fix fields per docs: %w", err)
}
return err
} Prevention
- Keep cache config YAML minimal: only type and config keys.
- Validate config files in CI before deploying.
- Copy examples from the matching Thanos version's docs.
- Prefer CLI flags where available to avoid YAML schema drift.
When it happens
Trigger: The YAML passed to NewCacheConfig does not strictly unmarshal into CacheProviderConfig: unknown keys (strict mode), wrong types, or invalid YAML syntax.
Common situations: Typos in YAML keys, using Cortex fields unsupported by Thanos's strict schema, copying configs between Thanos versions where fields changed, or malformed YAML indentation.
Related errors
- marshal content of cache backend configuration
- initializing the query range cache config
- initializing the labels cache config
- response cache with type
- invalid ResultsCache config for labels tripperware
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/c5785f0cee611c9a.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/queryfrontend/config.go:92
// RedisResponseCacheConfig holds the configs for the redis cache provider.
type RedisResponseCacheConfig struct {
Redis cacheutil.RedisClientConfig `yaml:",inline"`
// Expiration sets a global expiration limit for all cached items.
Expiration time.Duration `yaml:"expiration"`
}
// CacheProviderConfig is the initial CacheProviderConfig struct holder before parsing it into a specific cache provider.
// Based on the config type the config is then parsed into a specific cache provider.
type CacheProviderConfig struct {
Type ResponseCacheProvider `yaml:"type"`
Config any `yaml:"config"`
}
// NewCacheConfig is a parser that converts a Thanos cache config yaml into a cortex cache config struct.
func NewCacheConfig(logger log.Logger, confContentYaml []byte) (*cortexcache.Config, error) {
cacheConfig := &CacheProviderConfig{}
if err := yaml.UnmarshalStrict(confContentYaml, cacheConfig); err != nil {
return nil, errors.Wrap(err, "parsing config YAML file")
}
backendConfig, err := yaml.Marshal(cacheConfig.Config)
if err != nil {
return nil, errors.Wrap(err, "marshal content of cache backend configuration")
}
switch strings.ToUpper(string(cacheConfig.Type)) {
case string(INMEMORY):
var config InMemoryResponseCacheConfig
if err := yaml.Unmarshal(backendConfig, &config); err != nil {
return nil, err
}
return &cortexcache.Config{
EnableFifoCache: true,
Fifocache: cortexcache.FifoCacheConfig{
MaxSizeBytes: config.MaxSize,View on GitHub (pinned to 35b8b99117)