thanos-io/thanos · error

create gzip reader

Error message

create gzip reader

What it means

Wraps gzip.NewReader in Reloader.normalize: the config file's first bytes match the gzip magic, but a gzip stream cannot be initialized over the content (corrupt header, truncated archive). Decompression of the bundled config fails before env expansion.

Solutions

  1. Re-upload or regenerate the gzipped config.
  2. Verify the source file is a complete gzip archive.
  3. If the config is plain text, fix the leading bytes.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/reloader/reloader.go:371 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at pkg/reloader/reloader.go:371

		if err := r.apply(applyCtx); err != nil {
			r.configApplyErrors.Inc()
			level.Error(r.logger).Log("msg", "apply error", "err", err)
			continue
		}
	}
}

func (r *Reloader) normalize(inputFile, outputFile string) error {
	b, err := os.ReadFile(inputFile)
	if err != nil {
		return errors.Wrap(err, "read file")
	}

	// Detect and extract gzipped file.
	if bytes.Equal(b[0:3], firstGzipBytes) {
		zr, err := gzip.NewReader(bytes.NewReader(b))
		if err != nil {
			return errors.Wrap(err, "create gzip reader")
		}
		defer runutil.CloseWithLogOnErr(r.logger, zr, "gzip reader close")

		b, err = io.ReadAll(zr)
		if err != nil {
			return errors.Wrap(err, "read compressed config file")
		}
	}

	b, err = r.expandEnv(b)
	if err != nil {
		return errors.Wrap(err, "expand environment variables")
	}

	tmpFile := outputFile + ".tmp"
	defer func() {
		_ = os.Remove(tmpFile)
	}()

View on GitHub (pinned to 35b8b99117)