{"record":{"id":"c5785f0cee611c9a","repo":"thanos-io/thanos","slug":"parsing-config-yaml-file-c5785f","errorCode":null,"errorMessage":"parsing config YAML file","messagePattern":"parsing config YAML file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/queryfrontend/config.go","lineNumber":92,"sourceCode":"// RedisResponseCacheConfig holds the configs for the redis cache provider.\ntype RedisResponseCacheConfig struct {\n\tRedis cacheutil.RedisClientConfig `yaml:\",inline\"`\n\t// Expiration sets a global expiration limit for all cached items.\n\tExpiration time.Duration `yaml:\"expiration\"`\n}\n\n// CacheProviderConfig is the initial CacheProviderConfig struct holder before parsing it into a specific cache provider.\n// Based on the config type the config is then parsed into a specific cache provider.\ntype CacheProviderConfig struct {\n\tType   ResponseCacheProvider `yaml:\"type\"`\n\tConfig any                   `yaml:\"config\"`\n}\n\n// NewCacheConfig is a parser that converts a Thanos cache config yaml into a cortex cache config struct.\nfunc NewCacheConfig(logger log.Logger, confContentYaml []byte) (*cortexcache.Config, error) {\n\tcacheConfig := &CacheProviderConfig{}\n\tif err := yaml.UnmarshalStrict(confContentYaml, cacheConfig); err != nil {\n\t\treturn nil, errors.Wrap(err, \"parsing config YAML file\")\n\t}\n\n\tbackendConfig, err := yaml.Marshal(cacheConfig.Config)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"marshal content of cache backend configuration\")\n\t}\n\n\tswitch strings.ToUpper(string(cacheConfig.Type)) {\n\tcase string(INMEMORY):\n\t\tvar config InMemoryResponseCacheConfig\n\t\tif err := yaml.Unmarshal(backendConfig, &config); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn &cortexcache.Config{\n\t\t\tEnableFifoCache: true,\n\t\t\tFifocache: cortexcache.FifoCacheConfig{\n\t\t\t\tMaxSizeBytes: config.MaxSize,","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/queryfrontend/config.go#L74-L110","documentation":"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.","triggerScenarios":"The YAML passed to NewCacheConfig does not strictly unmarshal into CacheProviderConfig: unknown keys (strict mode), wrong types, or invalid YAML syntax.","commonSituations":"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.","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."],"exampleFix":"# before\ncache:\n  type: memcached\n  memcached:\n    addresses: [localhost:11211]\n# after\ntype: MEMCACHED\nconfig:\n  addresses: [localhost:11211]","handlingStrategy":"validation","validationCode":"// validate cache YAML before handing to Thanos\nvar probe struct {\n    Type   string                 `yaml:\"type\"`\n    Config map[string]interface{} `yaml:\"config\"`\n}\nif err := yaml.UnmarshalStrict(data, &probe); err != nil {\n    return fmt.Errorf(\"invalid cache config: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"cfg, err := queryfrontend.NewCacheConfig(logger, yamlBytes)\nif err != nil {\n    if strings.Contains(err.Error(), \"parsing config YAML file\") {\n        return fmt.Errorf(\"cache config YAML invalid, fix fields per docs: %w\", err)\n    }\n    return err\n}","preventionTips":["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."],"tags":["config","yaml","query-frontend","cache"],"backgroundTag":"yaml-parse-error","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"}