{"record":{"id":"19af35ad6af84d1a","repo":"thanos-io/thanos","slug":"parsing-config-yaml-file-19af35","errorCode":null,"errorMessage":"parsing config YAML file","messagePattern":"parsing config YAML file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/cache/caching_bucket_factory.go","lineNumber":84,"sourceCode":"\tcfg.ChunkObjectAttrsTTL = 24 * time.Hour\n\tcfg.ChunkSubrangeTTL = 24 * time.Hour\n\tcfg.MaxChunksGetRangeRequests = 3\n\tcfg.BlocksIterTTL = 5 * time.Minute\n\tcfg.MetafileExistsTTL = 2 * time.Hour\n\tcfg.MetafileDoesntExistTTL = 15 * time.Minute\n\tcfg.MetafileContentTTL = 24 * time.Hour\n\tcfg.MetafileMaxSize = 1024 * 1024 // Equal to default MaxItemSize in memcached client.\n}\n\n// NewCachingBucketFromYaml uses YAML configuration to create new caching bucket.\nfunc NewCachingBucketFromYaml(yamlContent []byte, bucket objstore.Bucket, logger log.Logger, reg prometheus.Registerer, r *route.Router, configPath string) (objstore.InstrumentedBucket, error) {\n\tlevel.Info(logger).Log(\"msg\", \"loading caching bucket configuration\")\n\n\tconfig := &CachingWithBackendConfig{}\n\tconfig.Defaults()\n\n\tif err := yaml.UnmarshalStrict(yamlContent, config); err != nil {\n\t\treturn nil, errors.Wrap(err, \"parsing config YAML file\")\n\t}\n\n\t// Append the config path to the YAML content. This allows\n\t// using identical config with multiple instances.\n\t// TODO(GiedriusS): in the long-term add some kind of \"name\"\n\t// identifier for each instance.\n\tcfgHash := string(fmt.Sprintf(\"%d\", xxhash.Sum64(append(yamlContent, []byte(configPath)...))))\n\n\tbackendConfig, err := yaml.Marshal(config.BackendConfig)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"marshal content of cache backend configuration\")\n\t}\n\n\tvar c cache.Cache\n\tcfg := cache.NewCachingBucketConfig()\n\n\t// Configure cache paths.\n\tcfg.CacheAttributes(\"chunks\", nil, isTSDBChunkFile, config.ChunkObjectAttrsTTL)","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/cache/caching_bucket_factory.go#L66-L102","documentation":"NewCachingBucketFromYaml parses the user-supplied YAML caching-bucket configuration with yaml.UnmarshalStrict into CachingWithBackendConfig; any parse error (unknown fields due to strict mode, bad types, malformed YAML) is wrapped as 'parsing config YAML file'. The library throws it because a valid config struct is required before a cache can be constructed.","triggerScenarios":"Calling NewCachingBucketFromYaml with YAML content that is syntactically invalid, contains unknown keys (strict unmarshalling), or has values of the wrong type (e.g. duration strings, enum values).","commonSituations":"Typos in Thanos store-gateway caching config keys, missing indentation in the embedded YAML, using deprecated or renamed fields after a Thanos upgrade, or passing flag-joined YAML that does not parse.","solutions":["Validate the YAML with a YAML linter and against the CachingWithBackendConfig schema","Remove or correct unknown keys — strict unmarshalling rejects unrecognized fields","Check the Thanos version's docs for current field names and types (renames happen across releases)","Compare against a known-good config from the Thanos repository docs (caching_bucket.md)","Fix the reported line: the wrapped error names the exact YAML problem"],"exampleFix":"// before\nconfig:\n  caches:\n    chunks:\n      maxsize: 500MB        # wrong: unknown field + wrong type\n// after\nconfig:\n  caches:\n    chunks:\n      max_size: 500MB\n      max_size_items: 0","handlingStrategy":"validation","validationCode":"var probe map[string]interface{}\nif err := yaml.Unmarshal(yamlContent, &probe); err != nil { return fmt.Errorf(\"invalid caching bucket YAML: %w\", err) }","typeGuard":null,"tryCatchPattern":"cb, err := storecache.NewCachingBucketFromYaml(yamlContent, logger, reg, bucket, router)\nif err != nil {\n    if strings.Contains(err.Error(), \"parsing config YAML file\") {\n        return fmt.Errorf(\"caching bucket config invalid, check unknown keys and types: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate YAML with strict parsing in CI before deploy","Only use field names from the Thanos docs for your exact version","Diff config against caching_bucket.md examples after upgrades","Keep durations and sizes in Go/YAML-supported formats (500ms, 512MB)"],"tags":["go","yaml","config","thanos"],"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"}