{"record":{"id":"e2094667d2ad4998","repo":"thanos-io/thanos","slug":"no-valid-chunk-found","errorCode":null,"errorMessage":"no valid chunk found","messagePattern":"no valid chunk found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/query/iter.go","lineNumber":184,"sourceCode":"\t\tsit = newChunkSeriesIterator(its)\n\tdefault:\n\t\treturn errSeriesIterator{err: errors.Errorf(\"unexpected result aggregate type %v\", s.aggrs)}\n\t}\n\treturn dedup.NewBoundedSeriesIterator(sit, s.mint, s.maxt)\n}\n\nfunc getFirstIterator(cs ...*storepb.Chunk) chunkenc.Iterator {\n\tfor _, c := range cs {\n\t\tif c == nil {\n\t\t\tcontinue\n\t\t}\n\t\tchk, err := chunkenc.FromData(chunkEncoding(c.Type), c.Data)\n\t\tif err != nil {\n\t\t\treturn errSeriesIterator{err}\n\t\t}\n\t\treturn chk.Iterator(nil)\n\t}\n\treturn errSeriesIterator{errors.New(\"no valid chunk found\")}\n}\n\nfunc chunkEncoding(e storepb.Chunk_Encoding) chunkenc.Encoding {\n\tswitch e {\n\tcase storepb.Chunk_XOR:\n\t\treturn chunkenc.EncXOR\n\tcase storepb.Chunk_HISTOGRAM:\n\t\treturn chunkenc.EncHistogram\n\tcase storepb.Chunk_FLOAT_HISTOGRAM:\n\t\treturn chunkenc.EncFloatHistogram\n\t}\n\treturn 255 // Invalid.\n}\n\ntype errSeriesIterator struct {\n\terr error\n}\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/query/iter.go#L166-L202","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the queried time range actually overlaps data present in the store (check store /api/v1/blocks or bucket blocks)","Check for clock skew or incorrect time range parameters in the query","Inspect blocks for the series to confirm MinTime/MaxTime coverage","Upgrade Thanos; some out-of-range seek cases were fixed to return empty iterators instead of errors"],"exampleFix":"// before: querying range outside available data\nqueryTime := time.Now() // data only exists until yesterday\n// after: clamp query range to available block boundaries\nif queryTime.After(maxAvailableTime) {\n    queryTime = maxAvailableTime\n}","handlingStrategy":"validation","validationCode":"// ensure query range overlaps series chunks before iterating\nfunc rangeOverlaps(minT, maxT, start, end int64) bool {\n    return start <= maxT && end >= minT\n}","typeGuard":null,"tryCatchPattern":"ss := q.Select(ctx, hints, matchers...)\nfor ss.Next() {}\nif err := ss.Err(); err != nil {\n    if strings.Contains(err.Error(), \"no valid chunk found\") {\n        // treat as no data for range: return empty result\n        return storage.EmptySeriesSet(), nil\n    }\n    return nil, err\n}","preventionTips":["Clamp query time ranges to available block MinTime/MaxTime","Sync clocks across nodes (NTP)","Check block existence in the bucket before querying a range"],"tags":["thanos","query","iterator","chunks"],"backgroundTag":"empty-result-set","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"}