thanos-io/thanos · error

invalid FifoCache config

Error message

invalid FifoCache config

What it means

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'.

Solutions

  1. Read the wrapped humanize error in the message to see which value failed to parse.
  2. Use valid humanize formats: '100MB', '1GB', '512KB', or a plain integer of bytes.
  3. Leave the value empty (zero) to disable the size limit.
  4. Run config validation at startup to catch the malformed size before runtime.

Example fix

// before
fifocache:
  size: 10 meg
// after
fifocache:
  size: 10MB
Defensive patterns

Strategy: validation

Validate before calling

func validByteSize(s string) bool {
    if s == "" { return true }
    _, err := humanize.ParseBytes(s)
    return err == nil
}

Try / catch

bytes, err := parsebytes(cfg.Fifocache.Size)
if err != nil {
    var wrapped *errors.wrapError
    if errors.As(err, &wrapped) { /* show inner humanize reason */ }
    return fmt.Errorf("fifocache.size %q: %w", cfg.Fifocache.Size, err)
}

Prevention

When it happens

Trigger: 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().

Common situations: 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).

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/4031085d9c37b679. Report an issue: GitHub.

Appendix: source

Thrown at internal/cortex/chunk/cache/fifo_cache.go:61

	f.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.")
	f.IntVar(&cfg.MaxSizeItems, prefix+"fifocache.max-size-items", 0, description+"Maximum number of entries in the cache.")
	f.DurationVar(&cfg.Validity, prefix+"fifocache.duration", 0, description+"The expiry duration for the cache.")

	f.IntVar(&cfg.DeprecatedSize, prefix+"fifocache.size", 0, "Deprecated (use max-size-items or max-size-bytes instead): "+description+"The number of entries to cache. ")
}

func (cfg *FifoCacheConfig) Validate() error {
	_, err := parsebytes(cfg.MaxSizeBytes)
	return err
}

func parsebytes(s string) (uint64, error) {
	if len(s) == 0 {
		return 0, nil
	}
	bytes, err := humanize.ParseBytes(s)
	if err != nil {
		return 0, errors.Wrap(err, "invalid FifoCache config")
	}
	return bytes, nil
}

// FifoCache is a simple string -> interface{} cache which uses a fifo slide to
// manage evictions.  O(1) inserts and updates, O(1) gets.
type FifoCache struct {
	lock          sync.RWMutex
	maxSizeItems  int
	maxSizeBytes  uint64
	currSizeBytes uint64
	validity      time.Duration

	entries map[string]*list.Element
	lru     *list.List

	entriesAdded    prometheus.Counter
	entriesAddedNew prometheus.Counter

View on GitHub (pinned to 35b8b99117)