{"record":{"id":"4031085d9c37b679","repo":"thanos-io/thanos","slug":"invalid-fifocache-config","errorCode":null,"errorMessage":"invalid FifoCache config","messagePattern":"invalid FifoCache config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cortex/chunk/cache/fifo_cache.go","lineNumber":61,"sourceCode":"\tf.StringVar(&cfg.MaxSizeBytes, prefix+\"fifocache.max-size-bytes\", \"\", description+\"Maximum memory size of the cache in bytes. A unit suffix (KB, MB, GB) may be applied.\")\n\tf.IntVar(&cfg.MaxSizeItems, prefix+\"fifocache.max-size-items\", 0, description+\"Maximum number of entries in the cache.\")\n\tf.DurationVar(&cfg.Validity, prefix+\"fifocache.duration\", 0, description+\"The expiry duration for the cache.\")\n\n\tf.IntVar(&cfg.DeprecatedSize, prefix+\"fifocache.size\", 0, \"Deprecated (use max-size-items or max-size-bytes instead): \"+description+\"The number of entries to cache. \")\n}\n\nfunc (cfg *FifoCacheConfig) Validate() error {\n\t_, err := parsebytes(cfg.MaxSizeBytes)\n\treturn err\n}\n\nfunc parsebytes(s string) (uint64, error) {\n\tif len(s) == 0 {\n\t\treturn 0, nil\n\t}\n\tbytes, err := humanize.ParseBytes(s)\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, \"invalid FifoCache config\")\n\t}\n\treturn bytes, nil\n}\n\n// FifoCache is a simple string -> interface{} cache which uses a fifo slide to\n// manage evictions.  O(1) inserts and updates, O(1) gets.\ntype FifoCache struct {\n\tlock          sync.RWMutex\n\tmaxSizeItems  int\n\tmaxSizeBytes  uint64\n\tcurrSizeBytes uint64\n\tvalidity      time.Duration\n\n\tentries map[string]*list.Element\n\tlru     *list.List\n\n\tentriesAdded    prometheus.Counter\n\tentriesAddedNew prometheus.Counter","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/internal/cortex/chunk/cache/fifo_cache.go#L43-L79","documentation":"parsebytes parses human-readable byte-size strings for the FifoCache config and wraps any humanize.ParseBytes failure with 'invalid FifoCache config'. Called from FifoCache Validate() and NewFifoCache, it fails when the size string (e.g. max_size_bytes) is not a valid quantity like '100MB'.","triggerScenarios":"Setting fifocache.size or fifocache validity-related byte-size config fields to a malformed string such as '10 meg', '1GiBx', or a non-numeric value, then calling Validate() or NewFifoCache().","commonSituations":"Hand-edited YAML with a typo'd size suffix; passing an empty-but-whitespace value; using units humanize doesn't understand (e.g. 'kib' lowercase without space).","solutions":["Read the wrapped humanize error in the message to see which value failed to parse.","Use valid humanize formats: '100MB', '1GB', '512KB', or a plain integer of bytes.","Leave the value empty (zero) to disable the size limit.","Run config validation at startup to catch the malformed size before runtime."],"exampleFix":"// before\nfifocache:\n  size: 10 meg\n// after\nfifocache:\n  size: 10MB","handlingStrategy":"validation","validationCode":"func validByteSize(s string) bool {\n    if s == \"\" { return true }\n    _, err := humanize.ParseBytes(s)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"bytes, err := parsebytes(cfg.Fifocache.Size)\nif err != nil {\n    var wrapped *errors.wrapError\n    if errors.As(err, &wrapped) { /* show inner humanize reason */ }\n    return fmt.Errorf(\"fifocache.size %q: %w\", cfg.Fifocache.Size, err)\n}","preventionTips":["Use canonical suffixes: KB/MB/GB (or plain byte integers).","Lint size fields in YAML configs against a byte-size regex.","Leave the field empty to use defaults instead of guessing units."],"tags":["config","validation","cache"],"backgroundTag":"invalid-config-value","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"}