thanos-io/thanos · error
received status code: 200, unknown response type
Error message
received status code: 200, unknown response type: '%q'
What it means
QueryInstant got a 200 OK but the response's Data.ResultType was none of the result types the client knows how to decode (vector, matrix, scalar, string). The library treats this as an unknown/undecodable response shape and refuses to parse it rather than returning garbage. It almost always indicates an API contract mismatch between the client and the Prometheus/Thanos server.
Solutions
- Verify the endpoint is a compatible Prometheus/Thanos /api/v1/query implementation; check server version against the thanos/tls promclient version and upgrade the client library if the server is newer.
- Dump the raw JSON response (curl the same URL) to see what ResultType is actually returned and compare with the handled cases in the client switch.
- Check for a misbehaving proxy/gateway between the client and Prometheus that alters the response body.
- If m.Data was empty because of a server-side issue, fix the server or adjust the query so it returns a normal vector/matrix result.
Example fix
// before
client := promclient.NewClientWithDetails("http://incompatible-proxy:9090", true, true, false)
// after
client := promclient.NewClientWithDetails("http://prometheus:9090", true, true, false)
// and pin/upgrade client to match the server API version Defensive patterns
Strategy: type-guard
Validate before calling
// Pre-flight the endpoint's API compatibility
resp, err := http.Get(base + "/api/v1/status/buildinfo")
if err != nil || resp.StatusCode != 200 {
return fmt.Errorf("endpoint is not a compatible Prometheus API")
} Type guard
func isUnknownResultTypeError(err error) bool {
return err != nil && strings.Contains(err.Error(), "unknown response type")
} Try / catch
res, _, _, err := api.PromqlQueryInstant(ctx, q, ts)
if err != nil && strings.Contains(err.Error(), "unknown response type") {
// API contract mismatch: fail fast, don't retry
return fmt.Errorf("incompatible prometheus endpoint/version: %w", err)
} Prevention
- Pin the client library version to match the Prometheus/Thanos server version
- Point clients only at genuine /api/v1 implementations, not rewriting proxies
- On upgrade of the server, run a smoke instant query before production traffic
When it happens
Trigger: Calling PromqlQueryInstant against a Prometheus/Thanos server that returns a ResultType the client's switch does not handle (newer API surface, proxy injecting different payload, or a response with empty/missing Data where ResultType serializes as an empty string).
Common situations: Pointing the client at a non-Prometheus or incompatible-version endpoint (e.g. newer Thanos Query API with an additional result type), a misconfigured reverse proxy rewriting responses, or an empty Data field due to a server bug.
Related errors
- failed to create matchers cache
- failed to validate prometheus flags
- failed to get prometheus version
- initial external labels query
- no external labels configured on Prometheus server…
AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07).
Data as JSON: /api/errors/248792548669db71.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/promclient/promclient.go:499
// Currently only `vector` and `scalar` types are supported.
switch m.Data.ResultType {
case string(parser.ValueTypeVector):
if err = json.Unmarshal(m.Data.Result, &vectorResult); err != nil {
return nil, nil, nil, errors.Wrap(err, "decode result into ValueTypeVector")
}
case string(parser.ValueTypeScalar):
vectorResult, err = convertScalarJSONToVector(m.Data.Result)
if err != nil {
return nil, nil, nil, errors.Wrap(err, "decode result into ValueTypeScalar")
}
default:
if m.Warnings != nil {
return nil, nil, nil, errors.Errorf("error: %s, type: %s, warning: %s", m.Error, m.ErrorType, strings.Join(m.Warnings, ", "))
}
if m.Error != "" {
return nil, nil, nil, errors.Errorf("error: %s, type: %s", m.Error, m.ErrorType)
}
return nil, nil, nil, errors.Errorf("received status code: 200, unknown response type: '%q'", m.Data.ResultType)
}
return vectorResult, m.Warnings, m.Data.Explanation, nil
}
// PromqlQueryInstant performs instant query and returns results in promql.Vector type that is compatible with promql package.
func (c *Client) PromqlQueryInstant(ctx context.Context, base *url.URL, query string, t time.Time, opts QueryOptions) (promql.Vector, []string, error) {
vectorResult, warnings, _, err := c.QueryInstant(ctx, base, query, t, opts)
if err != nil {
return nil, nil, err
}
vec := make(promql.Vector, 0, len(vectorResult))
b := labels.NewScratchBuilder(0)
for _, e := range vectorResult {
b.Reset()
View on GitHub (pinned to 35b8b99117)