{"record":{"id":"5ec7fc70f82911b5","repo":"thanos-io/thanos","slug":"invalid-rules-parameter-type-v","errorCode":null,"errorMessage":"invalid rules parameter type='%v'","messagePattern":"invalid rules parameter type='(.+?)'","errorType":"http","errorClass":"ApiError","httpStatus":400,"severity":"error","filePath":"pkg/api/query/v1.go","lineNumber":1475,"sourceCode":"\tif enablePartialResponse {\n\t\tps = storepb.PartialResponseStrategy_WARN\n\t}\n\n\treturn func(r *http.Request) (any, []error, *api.ApiError, func()) {\n\t\tspan, ctx := tracing.StartSpan(r.Context(), \"receive_http_request\")\n\t\tdefer span.Finish()\n\n\t\tvar (\n\t\t\tgroups   *rulespb.RuleGroups\n\t\t\twarnings annotations.Annotations\n\t\t\terr      error\n\t\t)\n\n\t\ttypeParam := r.URL.Query().Get(\"type\")\n\t\ttyp, ok := rulespb.RulesRequest_Type_value[strings.ToUpper(typeParam)]\n\t\tif !ok {\n\t\t\tif typeParam != \"\" {\n\t\t\t\treturn nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: errors.Errorf(\"invalid rules parameter type='%v'\", typeParam)}, func() {}\n\t\t\t}\n\t\t\ttyp = int32(rulespb.RulesRequest_ALL)\n\t\t}\n\n\t\tif err := r.ParseForm(); err != nil {\n\t\t\treturn nil, nil, &api.ApiError{Typ: api.ErrorInternal, Err: errors.Errorf(\"error parsing request form='%v'\", MatcherParam)}, func() {}\n\t\t}\n\n\t\t// TODO(bwplotka): Allow exactly the same functionality as query API: passing replica, dedup and partial response as HTTP params as well.\n\t\treq := &rulespb.RulesRequest{\n\t\t\tType:                    rulespb.RulesRequest_Type(typ),\n\t\t\tPartialResponseStrategy: ps,\n\t\t\tMatcherString:           r.Form[MatcherParam],\n\t\t\tRuleName:                r.Form[RuleNameParam],\n\t\t\tRuleGroup:               r.Form[RuleGroupParam],\n\t\t\tFile:                    r.Form[FileParam],\n\t\t}\n\t\ttracing.DoInSpan(ctx, \"retrieve_rules\", func(ctx context.Context) {","sourceCodeStart":1457,"sourceCodeEnd":1493,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/api/query/v1.go#L1457-L1493","documentation":"Returned by the /api/v1/rules endpoint when the 'type' query parameter is a non-empty value that doesn't match a RulesRequest_Type enum value (ALL, ALERT, RECORD, or their variants). Like the targets state check, the value is uppercased and looked up in the protobuf enum map; unknown non-empty values yield ErrorBadData (HTTP 400).","triggerScenarios":"GET /api/v1/rules?type=alerting — only values matching the RulesRequest_Type enum (case-insensitive: all, alert, record) are accepted.","commonSituations":"Using Prometheus terminology like 'alerting'/'recording' instead of the proto enum values 'alert'/'record', typos, or assuming empty string means invalid — an empty type is allowed and defaults to ALL.","solutions":["Use one of the accepted values: all, alert, or record (case-insensitive).","Omit the 'type' parameter to get all rules.","Consult rulespb.RulesRequest_Type in pkg/store/labelpb or rules proto for exact enum names."],"exampleFix":"// before\ncurl 'http://query:9090/api/v1/rules?type=alerting'\n// after\ncurl 'http://query:9090/api/v1/rules?type=alert'","handlingStrategy":"validation","validationCode":"const allowed = ['all','alert','record'];\nconst typ = params.get('type');\nif (typ && !allowed.includes(typ.toLowerCase())) throw new Error(`invalid type='${typ}'; use all|alert|record`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Map Prometheus 'alerting'/'recording' to 'alert'/'record' before calling Thanos.","Omit type for the default ALL.","Centralize enum values in your API client."],"tags":["http","api","validation","enum"],"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"}