thanos-io/thanos · error

no valid chunk found

Error message

no valid chunk found

What it means

In Thanos' query engine, getFirstIterator scans a series' chunks to build an iterator for the current seek position. If no chunk satisfies the requested time range (all chunks end before the sought timestamp or start after it), it falls through and wraps an errSeriesIterator with 'no valid chunk found'.

Solutions

  1. Verify the queried time range actually overlaps data present in the store (check store /api/v1/blocks or bucket blocks)
  2. Check for clock skew or incorrect time range parameters in the query
  3. Inspect blocks for the series to confirm MinTime/MaxTime coverage
  4. Upgrade Thanos; some out-of-range seek cases were fixed to return empty iterators instead of errors

Example fix

// before: querying range outside available data
queryTime := time.Now() // data only exists until yesterday
// after: clamp query range to available block boundaries
if queryTime.After(maxAvailableTime) {
    queryTime = maxAvailableTime
}
Defensive patterns

Strategy: validation

Validate before calling

// ensure query range overlaps series chunks before iterating
func rangeOverlaps(minT, maxT, start, end int64) bool {
    return start <= maxT && end >= minT
}

Try / catch

ss := q.Select(ctx, hints, matchers...)
for ss.Next() {}
if err := ss.Err(); err != nil {
    if strings.Contains(err.Error(), "no valid chunk found") {
        // treat as no data for range: return empty result
        return storage.EmptySeriesSet(), nil
    }
    return nil, err
}

Prevention

When it happens

Trigger: Calling SeriesSet iterator navigation (Seek/Next) at a timestamp outside the stored chunk boundaries of the series, e.g. seeking past the last chunk's MaxTime or before the first chunk's MinTime.

Common situations: Query time ranges misaligned with stored data (clock skew, wrong time zone, querying a block store where blocks for the range were compacted/deleted), or stale store responses after block deletion.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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

Appendix: source

Thrown at pkg/query/iter.go:184

		sit = newChunkSeriesIterator(its)
	default:
		return errSeriesIterator{err: errors.Errorf("unexpected result aggregate type %v", s.aggrs)}
	}
	return dedup.NewBoundedSeriesIterator(sit, s.mint, s.maxt)
}

func getFirstIterator(cs ...*storepb.Chunk) chunkenc.Iterator {
	for _, c := range cs {
		if c == nil {
			continue
		}
		chk, err := chunkenc.FromData(chunkEncoding(c.Type), c.Data)
		if err != nil {
			return errSeriesIterator{err}
		}
		return chk.Iterator(nil)
	}
	return errSeriesIterator{errors.New("no valid chunk found")}
}

func chunkEncoding(e storepb.Chunk_Encoding) chunkenc.Encoding {
	switch e {
	case storepb.Chunk_XOR:
		return chunkenc.EncXOR
	case storepb.Chunk_HISTOGRAM:
		return chunkenc.EncHistogram
	case storepb.Chunk_FLOAT_HISTOGRAM:
		return chunkenc.EncFloatHistogram
	}
	return 255 // Invalid.
}

type errSeriesIterator struct {
	err error
}

View on GitHub (pinned to 35b8b99117)