thanos-io/thanos · error

please call Next before At

Error message

please call Next before At

What it means

A deliberate guard panic in the lazyRespSet iterator: At() was called before Next() had ever returned true, so l.lastResp is nil/uninitialized. This is iterator-protocol misuse by the caller, not a data or store problem — the series stream itself is fine.

Solutions

  1. Fix the calling code to only call At() after Next() returns true
  2. Check series-set iteration loops for calling At() on an untouched or exhausted set
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/store/proxy_merge.go:387 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/fc7f2bbf4957a675. Report an issue: GitHub.

Appendix: source

Thrown at pkg/store/proxy_merge.go:387

		l.dataOrFinishEvent.Wait()
		if l.noMoreData && l.rb.isEmpty() {
			break
		}
	}

	if !l.rb.isEmpty() {
		l.lastResp = l.rb.pop()
		return true
	}

	l.lastResp = nil
	return false
}

func (l *lazyRespSet) At() *storepb.SeriesResponse {
	// NB: don't need hold l.responsesMtx lock here, because a call site must not call At() and Next() concurrently.
	if !l.initialized {
		panic("please call Next before At")
	}

	return l.lastResp
}

func (l *lazyRespSet) Close() {
	l.bufferedResponsesMtx.Lock()
	l.closeSeries()
	l.rb.close()
	l.noMoreData = true
	l.dataOrFinishEvent.Signal()
	l.bufferedResponsesMtx.Unlock()

	<-l.donec

	l.shardMatcher.Close()
	_ = l.cl.CloseSend()
}

View on GitHub (pinned to 35b8b99117)