thanos-io/thanos · error

json encode no compact mark

Error message

json encode no compact mark

What it means

MarkForNoCompact failed to JSON-encode the NoCompactMark struct before upload. This is a serialization failure of an internally constructed struct, indicating a programming/field error rather than user input, and the block remains unmarked.

Solutions

  1. Check metadata.NoCompactMark struct fields for unsupported types
  2. This is an internal error; report with the wrapped cause if reproducible
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at pkg/block/block.go:402 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/018921da52b16303. Report an issue: GitHub.

Appendix: source

Thrown at pkg/block/block.go:402

	noCompactMarkExists, err := bkt.Exists(ctx, m)
	if err != nil {
		return errors.Wrapf(err, "check exists %s in bucket", m)
	}
	if noCompactMarkExists {
		level.Warn(logger).Log("msg", "requested to mark for no compaction, but file already exists; this should not happen; investigate", "err", errors.Errorf("file %s already exists in bucket", m))
		return nil
	}

	noCompactMark, err := json.Marshal(metadata.NoCompactMark{
		ID:      id,
		Version: metadata.NoCompactMarkVersion1,

		NoCompactTime: time.Now().Unix(),
		Reason:        reason,
		Details:       details,
	})
	if err != nil {
		return errors.Wrap(err, "json encode no compact mark")
	}

	if err := bkt.Upload(ctx, m, bytes.NewBuffer(noCompactMark)); err != nil {
		return errors.Wrapf(err, "upload file %s to bucket", m)
	}
	markedForNoCompact.Inc()
	level.Info(logger).Log("msg", "block has been marked for no compaction", "block", id)
	return nil
}

// MarkForNoDownsample creates a file which marks block to be not downsampled.
func MarkForNoDownsample(ctx context.Context, logger log.Logger, bkt objstore.Bucket, id ulid.ULID, reason metadata.NoDownsampleReason, details string, markedForNoDownsample prometheus.Counter) error {
	m := path.Join(id.String(), metadata.NoDownsampleMarkFilename)
	noDownsampleMarkExists, err := bkt.Exists(ctx, m)
	if err != nil {
		return errors.Wrapf(err, "check exists %s in bucket", m)
	}
	if noDownsampleMarkExists {

View on GitHub (pinned to 35b8b99117)