{"record":{"id":"1e9891ee7c9d6919","repo":"thanos-io/thanos","slug":"error-s-type-s-warning-s","errorCode":null,"errorMessage":"error: %s, type: %s, warning: %s","messagePattern":"error: (.+?), type: (.+?), warning: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/promclient/promclient.go","lineNumber":494,"sourceCode":"\t}\n\n\tvar vectorResult model.Vector\n\n\t// Decode the Result depending on the ResultType\n\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))","sourceCodeStart":476,"sourceCodeEnd":512,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/promclient/promclient.go#L476-L512","documentation":"This error is raised when an instant query response has a resultType other than 'vector' or 'scalar' but carries a Prometheus error string and warnings — the API returned an error envelope (status success/200 with data.resultType such as 'string', 'matrix', or an error type). The library surfaces the server's error, errorType, and joined warnings verbatim via errors.Errorf with format 'error: %s, type: %s, warning: %s'.","triggerScenarios":"PromqlQueryInstant receives a response whose m.Data.ResultType is neither vector nor scalar AND m.Warnings is non-nil: the query produced warnings (e.g. instrumentation issues, duplicates) and/or an API-level error reported by the server or Thanos Querier.","commonSituations":"Thanos/Thanos-Querier returning warnings alongside results; querying a backend that answers resultType 'string' or 'matrix' for the expression; rate-limit or expansion-limit errors reported by the server in the success envelope; server-side timeout flagged in errorType.","solutions":["Read the embedded m.Error / m.ErrorType / warnings in the message and fix the query accordingly (e.g. simplify expression, reduce time range)","Handle warnings explicitly — inspect m.Warnings via the returned warnings slice if supported, or adjust the query to avoid them","If a string/matrix result is expected, use the appropriate API call (QueryRange for matrix) instead of instant query","Check Thanos-side limits (e.g. --query.max-concurrency, partial-response settings) when warnings come from Thanos","Retry only if errorType indicates a transient condition"],"exampleFix":"// before\nresult, _, _, err := client.PromqlQueryInstant(ctx, &promclient.QueryOptions{Query: \"some_very_expensive_query\"})\n// err: error: query timeout, type: timeout, warning: ...\n// after\n// use QueryRange or reduce scope\nresult, _, warn, err := client.PromqlQueryRange(ctx, &promclient.QueryRangeOptions{\n    Query: \"rate(http_requests_total[1m])\", Start: start, End: end, Step: step,\n})","handlingStrategy":"try-catch","validationCode":"// preflight: know which resultType your expression produces\n_, err := parser.ParseExpr(query)\nif err != nil {\n    return fmt.Errorf(\"invalid PromQL: %w\", err)\n}\n// strings produce resultType \"string\" — avoid or handle in instant query\nif strings.HasPrefix(query, \"\\\"\") {\n    return errors.New(\"string literals are not supported by instant vector queries\")\n}","typeGuard":null,"tryCatchPattern":"result, _, warn, err := client.PromqlQueryInstant(ctx, opts)\nif err != nil {\n    var werr promclient.Error // or string-match the wrapped server error\n    msg := err.Error()\n    switch {\n    case strings.Contains(msg, \"timeout\"):\n        // simplify query / increase server limits\n    case strings.Contains(msg, \"warning\"):\n        // inspect warn and adjust query\n    }\n    return fmt.Errorf(\"query rejected by server: %w\", err)\n}","preventionTips":["Use QueryRange for expressions returning matrices","Review Thanos warnings configuration (partial response, dedup limits)","Keep queries within server limits (samples, concurrency, timeout)","Parse embedded errorType to distinguish transient vs permanent server errors"],"tags":["prometheus","api-error","query","warnings"],"backgroundTag":"api-error-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"}