{"record":{"id":"0746e069a6550c1b","repo":"thanos-io/thanos","slug":"got-empty-chunks","errorCode":null,"errorMessage":"got empty chunks","messagePattern":"got empty chunks","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query/iter.go","lineNumber":227,"sourceCode":"func (errSeriesIterator) AtFloatHistogram(*histogram.FloatHistogram) (int64, *histogram.FloatHistogram) {\n\treturn 0, nil\n}\nfunc (errSeriesIterator) AtT() int64    { return 0 }\nfunc (it errSeriesIterator) Err() error { return it.err }\n\n// chunkSeriesIterator implements a series iterator on top\n// of a list of time-sorted, non-overlapping chunks.\ntype chunkSeriesIterator struct {\n\tchunks  []chunkenc.Iterator\n\ti       int\n\tlastVal chunkenc.ValueType\n\n\tcur chunkenc.Iterator\n}\n\nfunc newChunkSeriesIterator(cs []chunkenc.Iterator) chunkenc.Iterator {\n\tif len(cs) == 0 {\n\t\treturn errSeriesIterator{err: errors.New(\"got empty chunks\")}\n\t}\n\treturn &chunkSeriesIterator{chunks: cs, cur: cs[0]}\n}\n\nfunc (it *chunkSeriesIterator) Seek(t int64) chunkenc.ValueType {\n\t// We generally expect the chunks already to be cut down\n\t// to the range we are interested in. There's not much to be gained from\n\t// hopping across chunks so we just call next until we reach t.\n\tfor {\n\t\tct := it.AtT()\n\t\tif ct >= t {\n\t\t\treturn it.lastVal\n\t\t}\n\t\tit.lastVal = it.Next()\n\t\tif it.lastVal == chunkenc.ValNone {\n\t\t\treturn chunkenc.ValNone\n\t\t}\n\t}","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/query/iter.go#L209-L245","documentation":"newChunkSeriesIterator requires at least one chunk iterator to construct a chunkSeriesIterator; it is an internal invariant that callers pass a non-empty slice. An empty slice indicates an upstream bug where zero chunk iterators were collected.","triggerScenarios":"Calling newChunkSeriesIterator with a nil/empty []chunkenc.Iterator, which happens only due to an internal defect in how Iterator assembles chunk iterators per series.","commonSituations":"Encountered as a symptom of a Thanos engine bug, usually alongside concurrent store failures or malformed series responses; rarely caused by user configuration.","solutions":["Report/inspect the calling code path — this signals an internal invariant violation, not user error","Check store responses for empty series data and verify store health","Upgrade Thanos to the latest patch release","File an issue with the query and store logs if reproducible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := ss.Err(); err != nil {\n    if strings.Contains(err.Error(), \"got empty chunks\") {\n        return storage.EmptySeriesSet(), nil // internal bug; degrade gracefully\n    }\n    return err\n}","preventionTips":["Keep Thanos patched to the latest release","Monitor for this error — report it upstream as an invariant violation","Avoid custom forks/patches around chunk iterator construction"],"tags":["thanos","query","iterator","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}