{"record":{"id":"248792548669db71","repo":"thanos-io/thanos","slug":"received-status-code-200-unknown-response-type","errorCode":null,"errorMessage":"received status code: 200, unknown response type: '%q'","messagePattern":"received status code: 200, unknown response type: '%q'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/promclient/promclient.go","lineNumber":499,"sourceCode":"\t// Currently only `vector` and `scalar` types are supported.\n\tswitch m.Data.ResultType {\n\tcase string(parser.ValueTypeVector):\n\t\tif err = json.Unmarshal(m.Data.Result, &vectorResult); err != nil {\n\t\t\treturn nil, nil, nil, errors.Wrap(err, \"decode result into ValueTypeVector\")\n\t\t}\n\tcase string(parser.ValueTypeScalar):\n\t\tvectorResult, err = convertScalarJSONToVector(m.Data.Result)\n\t\tif err != nil {\n\t\t\treturn nil, nil, nil, errors.Wrap(err, \"decode result into ValueTypeScalar\")\n\t\t}\n\tdefault:\n\t\tif m.Warnings != nil {\n\t\t\treturn nil, nil, nil, errors.Errorf(\"error: %s, type: %s, warning: %s\", m.Error, m.ErrorType, strings.Join(m.Warnings, \", \"))\n\t\t}\n\t\tif m.Error != \"\" {\n\t\t\treturn nil, nil, nil, errors.Errorf(\"error: %s, type: %s\", m.Error, m.ErrorType)\n\t\t}\n\t\treturn nil, nil, nil, errors.Errorf(\"received status code: 200, unknown response type: '%q'\", m.Data.ResultType)\n\t}\n\n\treturn vectorResult, m.Warnings, m.Data.Explanation, nil\n}\n\n// PromqlQueryInstant performs instant query and returns results in promql.Vector type that is compatible with promql package.\nfunc (c *Client) PromqlQueryInstant(ctx context.Context, base *url.URL, query string, t time.Time, opts QueryOptions) (promql.Vector, []string, error) {\n\tvectorResult, warnings, _, err := c.QueryInstant(ctx, base, query, t, opts)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\tvec := make(promql.Vector, 0, len(vectorResult))\n\n\tb := labels.NewScratchBuilder(0)\n\tfor _, e := range vectorResult {\n\t\tb.Reset()\n","sourceCodeStart":481,"sourceCodeEnd":517,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/promclient/promclient.go#L481-L517","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nclient := promclient.NewClientWithDetails(\"http://incompatible-proxy:9090\", true, true, false)\n// after\nclient := promclient.NewClientWithDetails(\"http://prometheus:9090\", true, true, false)\n// and pin/upgrade client to match the server API version","handlingStrategy":"type-guard","validationCode":"// Pre-flight the endpoint's API compatibility\nresp, err := http.Get(base + \"/api/v1/status/buildinfo\")\nif err != nil || resp.StatusCode != 200 {\n    return fmt.Errorf(\"endpoint is not a compatible Prometheus API\")\n}","typeGuard":"func isUnknownResultTypeError(err error) bool {\n    return err != nil && strings.Contains(err.Error(), \"unknown response type\")\n}","tryCatchPattern":"res, _, _, err := api.PromqlQueryInstant(ctx, q, ts)\nif err != nil && strings.Contains(err.Error(), \"unknown response type\") {\n    // API contract mismatch: fail fast, don't retry\n    return fmt.Errorf(\"incompatible prometheus endpoint/version: %w\", err)\n}","preventionTips":["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"],"tags":["prometheus","response-parsing","api-compatibility"],"backgroundTag":"unexpected-response-shape","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"}