{"record":{"id":"d4b79b4d247dc18f","repo":"thanos-io/thanos","slug":"s-parameter","errorCode":null,"errorMessage":"'%s' parameter","messagePattern":"'(.+?)' parameter","errorType":"validation","errorClass":"api.ApiError","httpStatus":400,"severity":"error","filePath":"pkg/api/query/v1.go","lineNumber":300,"sourceCode":"// operator that fetches data from storage.\ntype fanoutEntry struct {\n\tEndpointAddr   string `json:\"endpointAddr,omitempty\"`\n\tDuration       string `json:\"duration,omitempty\"`\n\tBytesProcessed int64  `json:\"bytesProcessed,omitempty\"`\n\tNumResponses   int64  `json:\"numResponses,omitempty\"`\n\tSeries         int64  `json:\"series,omitempty\"`\n\tChunks         int64  `json:\"chunks,omitempty\"`\n\tSamples        int64  `json:\"samples,omitempty\"`\n}\n\nfunc (qapi *QueryAPI) parseEnableDedupParam(r *http.Request) (enableDeduplication bool, _ *api.ApiError) {\n\tenableDeduplication = true\n\n\tif val := r.FormValue(DedupParam); val != \"\" {\n\t\tvar err error\n\t\tenableDeduplication, err = strconv.ParseBool(val)\n\t\tif err != nil {\n\t\t\treturn false, &api.ApiError{Typ: api.ErrorBadData, Err: errors.Wrapf(err, \"'%s' parameter\", DedupParam)}\n\t\t}\n\t}\n\treturn enableDeduplication, nil\n}\n\nfunc (qapi *QueryAPI) parseQueryParam(r *http.Request) string {\n\treturn r.FormValue(QueryParam)\n}\n\nfunc (qapi *QueryAPI) parseEngineParam(r *http.Request) (e PromqlEngineType, _ *api.ApiError) {\n\tparam := PromqlEngineType(r.FormValue(EngineParam))\n\tif param == \"\" {\n\t\tparam = qapi.defaultEngine\n\t}\n\tswitch param {\n\tcase PromqlEnginePrometheus, PromqlEngineThanos:\n\tdefault:\n\t\treturn param, &api.ApiError{Typ: api.ErrorBadData, Err: errors.Errorf(\"'%s' bad engine\", param)}","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/api/query/v1.go#L282-L318","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Send an exact Go boolean string: 'true', 'false', '1', '0', 't', 'f', 'T', 'F', 'TRUE', 'FALSE' etc.","Omit the parameter entirely to use the default (dedup enabled)","Sanitize/trim the value in the client before appending it to the URL","Check for duplicated params where a later bad value overwrites a good one"],"exampleFix":"// before\nGET /api/v1/query?query=up&deduplication=Yes\n// after\nGET /api/v1/query?query=up&deduplication=true","handlingStrategy":"validation","validationCode":"const boolRe = /^(true|false|1|0|t|f|T|F|TRUE|FALSE|True|False)$/;\nfunction toBoolParam(v) { if (!boolRe.test(v)) throw new Error(`bad bool: ${v}`); return v.toLowerCase() === 'true' || v === '1' || v.toLowerCase() === 't'; }","typeGuard":"function isGoBool(v) { return ['true','false','1','0','t','f'].includes(String(v).toLowerCase()); }","tryCatchPattern":"try {\n  const res = await fetch(url);\n  const body = await res.json();\n  if (body.status === 'error' && body.errorType === 'bad_data') throw new Error(body.error);\n} catch (e) {\n  if (/deduplication.*parameter/.test(e.message)) { /* fix the boolean and retry */ }\n  throw e;\n}","preventionTips":["Only emit Go-parseable booleans for bool query params","Trim and coerce config values (yes/no/on) before URL building","Omit optional bool params rather than guessing values","Add a shared URL-builder that validates bool params"],"tags":["http-api","query-parameter","boolean-parsing","thanos"],"backgroundTag":"invalid-query-parameter","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"}