thanos-io/thanos · error

unknown partial response strategy

Error message

unknown partial response strategy %v

What it means

QueryOptions.AddTo maps the PartialResponseStrategy enum onto the partial_response query parameter; only WARN and ABORT are supported. Any other (invalid or unexpected) strategy value makes it return this error, and QueryInstant/QueryRange propagate it. It protects against silently issuing a query with an unrecognized strategy.

Solutions

  1. Set PartialResponseStrategy explicitly to storepb.PartialResponseStrategy_WARN or _ABORT before querying
  2. Validate/normalize the strategy value when it originates from config or user input
  3. Rebuild against the current storepb package so enum values match
  4. Inspect the %v value in the error to identify which invalid constant was passed

Example fix

// before
opts := promclient.QueryOptions{} // zero-value strategy
// after
opts := promclient.QueryOptions{PartialResponseStrategy: storepb.PartialResponseStrategy_WARN}
Defensive patterns

Strategy: validation

Validate before calling

switch opts.PartialResponseStrategy {
case storepb.PartialResponseStrategy_WARN, storepb.PartialResponseStrategy_ABORT:
    // ok
default:
    return fmt.Errorf("unsupported strategy: %v", opts.PartialResponseStrategy)
}

Type guard

func validStrategy(s storepb.PartialResponseStrategy) bool {
    return s == storepb.PartialResponseStrategy_WARN || s == storepb.PartialResponseStrategy_ABORT
}

Try / catch

if err := opts.AddTo(params); err != nil {
    if strings.Contains(err.Error(), "unknown partial response strategy") {
        opts.PartialResponseStrategy = storepb.PartialResponseStrategy_WARN
        return opts.AddTo(params)
    }
    return err
}

Prevention

When it happens

Trigger: Passing QueryOptions with PartialResponseStrategy set to a value outside storepb.PartialResponseStrategy_WARN/ABORT — e.g. a zero-value enum from an unvalidated struct, or a strategy added in a newer storepb version not handled by this code.

Common situations: Constructing QueryOptions programmatically where the strategy comes from config parsing that does not validate the enum; copying options from another code path that uses a different enum type; upgrading Thanos and forgetting to handle new enum members in a switch.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at pkg/promclient/promclient.go:412

func (p *QueryOptions) AddTo(values url.Values) error {
	values.Add("dedup", fmt.Sprintf("%v", p.Deduplicate))
	if len(p.MaxSourceResolution) > 0 {
		values.Add("max_source_resolution", p.MaxSourceResolution)
	}

	values.Add("explain", fmt.Sprintf("%v", p.Explain))
	values.Add("analyze", fmt.Sprintf("%v", p.Analyze))
	values.Add("engine", p.Engine)

	var partialResponseValue string
	switch p.PartialResponseStrategy {
	case storepb.PartialResponseStrategy_WARN:
		partialResponseValue = strconv.FormatBool(true)
	case storepb.PartialResponseStrategy_ABORT:
		partialResponseValue = strconv.FormatBool(false)
	default:
		return errors.Errorf("unknown partial response strategy %v", p.PartialResponseStrategy)
	}

	// TODO(bwplotka): Apply change from bool to strategy in Query API as well.
	values.Add("partial_response", partialResponseValue)

	return nil
}

type Explanation struct {
	Name     string         `json:"name"`
	Children []*Explanation `json:"children,omitempty"`
}

// QueryInstant performs an instant query using a default HTTP client and returns results in model.Vector type.
func (c *Client) QueryInstant(ctx context.Context, base *url.URL, query string, t time.Time, opts QueryOptions) (model.Vector, []string, *Explanation, error) {
	params, err := url.ParseQuery(base.RawQuery)
	if err != nil {
		return nil, nil, nil, errors.Wrapf(err, "parse raw query %s", base.RawQuery)

View on GitHub (pinned to 35b8b99117)