{"record":{"id":"213ec1f0998c0040","repo":"thanos-io/thanos","slug":"engine-type-must-be-thanos","errorCode":null,"errorMessage":"engine type must be 'thanos'","messagePattern":"engine type must be 'thanos'","errorType":"validation","errorClass":"api.ApiError","httpStatus":400,"severity":"error","filePath":"pkg/api/query/v1.go","lineNumber":497,"sourceCode":"\t\t\t\tChunks:         s.Chunks,\n\t\t\t\tSamples:        s.Samples,\n\t\t\t})\n\t\t}\n\t}\n\tfor _, c := range a.Children {\n\t\tanalysis.Children = append(analysis.Children, processAnalysis(c, tracker))\n\t}\n\treturn analysis\n}\n\nfunc (qapi *QueryAPI) queryExplain(r *http.Request) (any, []error, *api.ApiError, func()) {\n\tengineParam, apiErr := qapi.parseEngineParam(r)\n\tif apiErr != nil {\n\t\treturn nil, nil, apiErr, func() {}\n\t}\n\n\tif engineParam != PromqlEngineThanos {\n\t\treturn nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: errors.New(\"engine type must be 'thanos'\")}, func() {}\n\t}\n\tqueryParam := qapi.parseQueryParam(r)\n\n\tts, err := parseTimeParam(r, \"time\", qapi.baseAPI.Now())\n\tif err != nil {\n\t\treturn nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: err}, func() {}\n\t}\n\n\tctx := r.Context()\n\tif to := r.FormValue(\"timeout\"); to != \"\" {\n\t\tvar cancel context.CancelFunc\n\t\ttimeout, err := parseDuration(to)\n\t\tif err != nil {\n\t\t\treturn nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: err}, func() {}\n\t\t}\n\n\t\tctx, cancel = context.WithTimeout(ctx, timeout)\n\t\tdefer cancel()","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/api/query/v1.go#L479-L515","documentation":"The query_explain endpoint only supports the Thanos engine because explain requires engine.ExplainableQuery. If the `engine` request parameter parses successfully but is anything other than 'thanos', queryExplain returns an HTTP 400 (api.ErrorBadData) with this message.","triggerScenarios":"Calling /api/v1/query_explain with `engine=prometheus` or any other value than 'thanos'.","commonSituations":"Copy-pasting query URLs between the regular query endpoint (which accepts prometheus) and the explain endpoint; clients with a configurable engine defaulting to prometheus while also calling explain.","solutions":["Set `engine=thanos` in the query_explain request.","Remove the engine parameter only if 'thanos' is the configured default; otherwise pass it explicitly.","Stop calling query_explain if you must use the Prometheus engine — explain is unsupported there."],"exampleFix":"// before\nGET /api/v1/query_explain?query=up&engine=prometheus\n// after\nGET /api/v1/query_explain?query=up&engine=thanos","handlingStrategy":"validation","validationCode":"if (engine !== undefined && engine !== 'thanos') {\n  throw new Error(\"query_explain only supports engine='thanos'\");\n}","typeGuard":"const isThanosEngine = (e) => e === undefined || e === 'thanos';","tryCatchPattern":"const body = await res.json();\nif (body.status === 'error' && /engine type must be 'thanos'/.test(body.error)) {\n  // correct the engine parameter and retry once\n}","preventionTips":["Hardcode engine=thanos for explain endpoints in clients.","Don't share a generic request builder between plain query and explain calls without an engine override.","Validate engine config values against the 'thanos'/'prometheus' enum client-side."],"tags":["http-api","query-explain","engine","bad-request"],"backgroundTag":"invalid-enum-value","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"}