thanos-io/thanos · error

unsupported compression type

Error message

unsupported compression type: %s

What it means

ResultsCacheConfig.Validate rejects any cfg.Compression value other than "snappy" or empty string. The results-cache payload compression is limited to snappy; any other codec name is a config error surfaced at startup/validation time.

Solutions

  1. Set compression to "snappy" or remove the flag to use the default
  2. Check `cortex -help` / config reference for supported compression values in your version
  3. Correct typos in the compression flag value

Example fix

# before
querier:
  results-cache:
    compression: gzip
# after
querier:
  results-cache:
    compression: snappy
Defensive patterns

Strategy: validation

Validate before calling

if cfg.Compression != "snappy" && cfg.Compression != "" {
	return fmt.Errorf("unsupported compression: %q, use snappy or unset", cfg.Compression)
}

Try / catch

if err := cfg.Validate(qCfg); err != nil {
	if strings.Contains(err.Error(), "unsupported compression") {
		cfg.Compression = "snappy"
	}
}

Prevention

When it happens

Trigger: Calling Config.Validate (or app startup) with `-querier.results-cache.compression` (yaml `compression`) set to something like "gzip", "zstd", or a typo such as "snavy".

Common situations: Copying config from another project that supports gzip cache compression; typos in the flag value; newer/older Cortex versions with different codec support.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at internal/cortex/querier/queryrange/results_cache.go:71

	CacheConfig                cache.Config `yaml:"cache"`
	Compression                string       `yaml:"compression"`
	CacheQueryableSamplesStats bool         `yaml:"cache_queryable_samples_stats"`
}

// RegisterFlags registers flags.
func (cfg *ResultsCacheConfig) RegisterFlags(f *flag.FlagSet) {
	cfg.CacheConfig.RegisterFlagsWithPrefix("frontend.", "", f)

	f.StringVar(&cfg.Compression, "frontend.compression", "", "Use compression in results cache. Supported values are: 'snappy' and '' (disable compression).")
	f.BoolVar(&cfg.CacheQueryableSamplesStats, "frontend.cache-queryable-samples-stats", false, "Cache Statistics queryable samples on results cache.")
}

func (cfg *ResultsCacheConfig) Validate(qCfg querier.Config) error {
	switch cfg.Compression {
	case "snappy", "":
		// valid
	default:
		return errors.Errorf("unsupported compression type: %s", cfg.Compression)
	}

	if cfg.CacheQueryableSamplesStats && !qCfg.EnablePerStepStats {
		return errors.New("frontend.cache-queryable-samples-stats may only be enabled in conjunction with querier.per-step-stats-enabled. Please set the latter")
	}

	return cfg.CacheConfig.Validate()
}

// Extractor is used by the cache to extract a subset of a response from a cache entry.
type Extractor interface {
	// Extract extracts a subset of a response from the `start` and `end` timestamps in milliseconds in the `from` response.
	Extract(start, end int64, from Response) Response
	ExtractForStep(start, end, step int64, from Response) Response
	ResponseWithoutHeaders(resp Response) Response
	ResponseWithoutStats(resp Response) Response
}

View on GitHub (pinned to 35b8b99117)