thanos-io/thanos · error

error: , type: , warning

Error message

error: %s, type: %s, warning: %s

What it means

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'.

Solutions

  1. Read the embedded m.Error / m.ErrorType / warnings in the message and fix the query accordingly (e.g. simplify expression, reduce time range)
  2. Handle warnings explicitly — inspect m.Warnings via the returned warnings slice if supported, or adjust the query to avoid them
  3. If a string/matrix result is expected, use the appropriate API call (QueryRange for matrix) instead of instant query
  4. Check Thanos-side limits (e.g. --query.max-concurrency, partial-response settings) when warnings come from Thanos
  5. Retry only if errorType indicates a transient condition

Example fix

// before
result, _, _, err := client.PromqlQueryInstant(ctx, &promclient.QueryOptions{Query: "some_very_expensive_query"})
// err: error: query timeout, type: timeout, warning: ...
// after
// use QueryRange or reduce scope
result, _, warn, err := client.PromqlQueryRange(ctx, &promclient.QueryRangeOptions{
    Query: "rate(http_requests_total[1m])", Start: start, End: end, Step: step,
})
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: know which resultType your expression produces
_, err := parser.ParseExpr(query)
if err != nil {
    return fmt.Errorf("invalid PromQL: %w", err)
}
// strings produce resultType "string" — avoid or handle in instant query
if strings.HasPrefix(query, "\"") {
    return errors.New("string literals are not supported by instant vector queries")
}

Try / catch

result, _, warn, err := client.PromqlQueryInstant(ctx, opts)
if err != nil {
    var werr promclient.Error // or string-match the wrapped server error
    msg := err.Error()
    switch {
    case strings.Contains(msg, "timeout"):
        // simplify query / increase server limits
    case strings.Contains(msg, "warning"):
        // inspect warn and adjust query
    }
    return fmt.Errorf("query rejected by server: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/1e9891ee7c9d6919. Report an issue: GitHub.

Appendix: source

Thrown at pkg/promclient/promclient.go:494

	}

	var vectorResult model.Vector

	// Decode the Result depending on the ResultType
	// 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))

View on GitHub (pinned to 35b8b99117)