{"record":{"id":"7f0fd3576d57e1f9","repo":"thanos-io/thanos","slug":"empty-data-field-in-tsdb-status-response","errorCode":null,"errorMessage":"empty data field in TSDB status response","messagePattern":"empty data field in TSDB status response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/promclient/promclient.go","lineNumber":983,"sourceCode":"\n\tq := u.Query()\n\tif len(matchers) > 0 {\n\t\tq.Add(\"match[]\", storepb.PromMatchersToString(matchers...))\n\t}\n\tif limit > 0 {\n\t\tq.Add(\"limit\", strconv.Itoa(limit))\n\t}\n\tu.RawQuery = q.Encode()\n\n\tvar v struct {\n\t\tData *statuspb.TSDBStatisticsEntry `json:\"data\"`\n\t}\n\tif err := c.get2xxResultWithGRPCErrors(ctx, \"/prom_status_tsdb HTTP[client]\", &u, &v); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif v.Data == nil {\n\t\treturn nil, errors.New(\"empty data field in TSDB status response\")\n\t}\n\treturn v.Data, nil\n}\n","sourceCodeStart":965,"sourceCodeEnd":987,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/promclient/promclient.go#L965-L987","documentation":"Client TSDB status retrieval (TSDBStatus/related /prom_status_tsdb call) performs a 2xx GET and decodes into a wrapper struct with a Data field. If the Prometheus API answered successfully but the JSON `data` field is null/absent, the client returns this sentinel error rather than returning a nil pointer.","triggerScenarios":"c.get2xxResultWithGRPCErrors succeeds but v.Data == nil — the queried Prometheus version does not populate data for the TSDB status endpoint (older versions, API disabled via --web.enable-admin-api semantics, or an incompatible proxy stripping the payload).","commonSituations":"Running against an old Prometheus lacking the /api/v1/status/tsdb endpoint shape; admin APIs disabled; intermediary (sidecar/proxy) returning {\"status\":\"success\"} with no data.","solutions":["Check the Prometheus version supports /api/v1/status/tsdb and upgrade if older.","Ensure the correct API path/flags (e.g. admin APIs enabled) on the target Prometheus.","Inspect the raw response body with curl to see whether data is null and why.","Handle the error in callers (e.g. skip TSDB stats collection for that endpoint) instead of crashing."],"exampleFix":"// before\nif v.Data == nil {\n\treturn nil, errors.New(\"empty data field in TSDB status response\")\n}\n\n// after (caller-side tolerant handling)\ndata, err := client.TSDBStatus(ctx)\nif err != nil {\n\tif strings.Contains(err.Error(), \"empty data field\") {\n\t\tlevel.Warn(logger).Log(\"msg\", \"TSDB status unavailable for endpoint; skipping\")\n\t\treturn nil, nil\n\t}\n\treturn nil, err\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":"type tsdbStatusWrapper struct { Data json.RawMessage `json:\"data\"` }\nfunc hasData(w tsdbStatusWrapper) bool { return len(w.Data) > 0 && string(w.Data) != \"null\" }","tryCatchPattern":"data, err := client.TSDBStatus(ctx)\nif err != nil {\n\tlevel.Warn(logger).Log(\"msg\", \"TSDB status unavailable, continuing without it\", \"err\", err)\n\tdata = nil // degrade gracefully\n}","preventionTips":["Confirm target Prometheus supports the TSDB status API for your version","Enable required admin/API flags on the target","Treat optional status endpoints as best-effort in callers"],"tags":["prometheus","api","empty-response","compatibility"],"backgroundTag":"empty-api-response","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"}