thanos-io/thanos · error · api.ApiError

' ' parameter

Error message

'%s' parameter

What it means

parseEnableDedupParam reads the 'deduplication' query/form parameter and parses it with strconv.ParseBool. On failure the error is wrapped as "'deduplication' parameter: ..." and returned as ErrorBadData. It means the deduplication value was not a recognized boolean literal.

Solutions

  1. Send an exact Go boolean string: 'true', 'false', '1', '0', 't', 'f', 'T', 'F', 'TRUE', 'FALSE' etc.
  2. Omit the parameter entirely to use the default (dedup enabled)
  3. Sanitize/trim the value in the client before appending it to the URL
  4. Check for duplicated params where a later bad value overwrites a good one

Example fix

// before
GET /api/v1/query?query=up&deduplication=Yes
// after
GET /api/v1/query?query=up&deduplication=true
Defensive patterns

Strategy: validation

Validate before calling

const boolRe = /^(true|false|1|0|t|f|T|F|TRUE|FALSE|True|False)$/;
function toBoolParam(v) { if (!boolRe.test(v)) throw new Error(`bad bool: ${v}`); return v.toLowerCase() === 'true' || v === '1' || v.toLowerCase() === 't'; }

Type guard

function isGoBool(v) { return ['true','false','1','0','t','f'].includes(String(v).toLowerCase()); }

Try / catch

try {
  const res = await fetch(url);
  const body = await res.json();
  if (body.status === 'error' && body.errorType === 'bad_data') throw new Error(body.error);
} catch (e) {
  if (/deduplication.*parameter/.test(e.message)) { /* fix the boolean and retry */ }
  throw e;
}

Prevention

When it happens

Trigger: Passing deduplication=yes/1?/on variants unsupported by ParseBool, e.g. deduplication=Yes, deduplication=truee, deduplication=2, or whitespace-padded values on query, query_range, series, or their explain endpoints.

Common situations: Constructing URLs in scripts where the value comes from untyped config or user input; YAML/JSON configs using truthy values like 'yes' that are not Go booleans; URL encoding issues inserting stray characters.

Understand the failure class

Background: "Invalid query parameter" / "Failed to parse value of ...": fixing bad query string parameters across APIs — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at pkg/api/query/v1.go:300

// operator that fetches data from storage.
type fanoutEntry struct {
	EndpointAddr   string `json:"endpointAddr,omitempty"`
	Duration       string `json:"duration,omitempty"`
	BytesProcessed int64  `json:"bytesProcessed,omitempty"`
	NumResponses   int64  `json:"numResponses,omitempty"`
	Series         int64  `json:"series,omitempty"`
	Chunks         int64  `json:"chunks,omitempty"`
	Samples        int64  `json:"samples,omitempty"`
}

func (qapi *QueryAPI) parseEnableDedupParam(r *http.Request) (enableDeduplication bool, _ *api.ApiError) {
	enableDeduplication = true

	if val := r.FormValue(DedupParam); val != "" {
		var err error
		enableDeduplication, err = strconv.ParseBool(val)
		if err != nil {
			return false, &api.ApiError{Typ: api.ErrorBadData, Err: errors.Wrapf(err, "'%s' parameter", DedupParam)}
		}
	}
	return enableDeduplication, nil
}

func (qapi *QueryAPI) parseQueryParam(r *http.Request) string {
	return r.FormValue(QueryParam)
}

func (qapi *QueryAPI) parseEngineParam(r *http.Request) (e PromqlEngineType, _ *api.ApiError) {
	param := PromqlEngineType(r.FormValue(EngineParam))
	if param == "" {
		param = qapi.defaultEngine
	}
	switch param {
	case PromqlEnginePrometheus, PromqlEngineThanos:
	default:
		return param, &api.ApiError{Typ: api.ErrorBadData, Err: errors.Errorf("'%s' bad engine", param)}

View on GitHub (pinned to 35b8b99117)