{"record":{"id":"a68f6a0cd0406e2c","repo":"SigNoz/signoz","slug":"invalid-operator-s","errorCode":null,"errorMessage":"invalid operator: %s","messagePattern":"invalid operator: (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":109,"sourceCode":"\t\tAggregateOperatorP95,\n\t\tAggregateOperatorP99,\n\t\tAggregateOperatorRate,\n\t\tAggregateOperatorSumRate,\n\t\tAggregateOperatorAvgRate,\n\t\tAggregateOperatorMinRate,\n\t\tAggregateOperatorMaxRate,\n\t\tAggregateOperatorRateSum,\n\t\tAggregateOperatorRateAvg,\n\t\tAggregateOperatorRateMin,\n\t\tAggregateOperatorRateMax,\n\t\tAggregateOperatorHistQuant50,\n\t\tAggregateOperatorHistQuant75,\n\t\tAggregateOperatorHistQuant90,\n\t\tAggregateOperatorHistQuant95,\n\t\tAggregateOperatorHistQuant99:\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"invalid operator: %s\", a)\n\t}\n}\n\n// RequireAttribute returns true if the aggregate operator requires an attribute\n// to be specified.\nfunc (a AggregateOperator) RequireAttribute(dataSource DataSource) bool {\n\tswitch dataSource {\n\tcase DataSourceMetrics:\n\t\tswitch a {\n\t\tcase AggregateOperatorNoOp,\n\t\t\tAggregateOperatorCount:\n\t\t\treturn false\n\t\tdefault:\n\t\t\treturn true\n\t\t}\n\tcase DataSourceLogs:\n\t\tswitch a {\n\t\tcase AggregateOperatorNoOp,","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L91-L127","documentation":"Thrown by AggregateOperator.Validate() in pkg/query-service/model/v3/v3.go when the aggregate operator string is not one of the recognized constants (sum, avg, min, max, p05/p10/.../p99 percentiles, rate_sum, rate_avg, rate_min, rate_max, hist_quant50/75/90/95/99, etc.). It is a plain enum validation: the API received an operator value it cannot map to a ClickHouse aggregation.","triggerScenarios":"Calling a v3 query API (e.g. POST /api/v3/query_range or autocomplete/aggregate-attribute endpoints) with QueryData.AggregateAttributeRequest.AggregateOperator set to a typo'd or unsupported value like \"Sum\", \"count_distinct\", \"p50\", or an empty string when the data source is not metrics.","commonSituations":"Frontend/CLI sending capitalized operator names, version skew where a newer client emits an operator this server build doesn't know yet, hand-crafted JSON payloads, or copy-pasting operator names from a different metrics DSL (PromQL function names like 'quantile' used as operator).","solutions":["Check the AggregateOperator constants in pkg/query-service/model/v3/v3.go for the exact accepted spellings and use one of them (lowercase, e.g. \"avg\", \"p95\", \"hist_quant99\")","Ensure JSON payloads use the exact enum string values; Go unmarshals case-sensitively for string-typed constants","If the value comes from user input, validate it client-side against the operator list before sending the request","If you need an operator you believe exists, upgrade the query-service to a version that supports it"],"exampleFix":"// before\nreq := &v3.AggregateAttributeRequest{\n    AggregateOperator: v3.AggregateOperator(\"P95\"),\n}\n\n// after\nreq := &v3.AggregateAttributeRequest{\n    AggregateOperator: v3.AggregateOperatorP95,\n}","handlingStrategy":"validation","validationCode":"validOps := map[v3.AggregateOperator]bool{v3.AggregateOperatorAvg:true,v3.AggregateOperatorSum:true,v3.AggregateOperatorMin:true,v3.AggregateOperatorMax:true,v3.AggregateOperatorP95:true} // extend as needed\nif !validOps[req.AggregateOperator] { return fmt.Errorf(\"unsupported operator %q\", req.AggregateOperator) }","typeGuard":"func isValidAggregateOperator(op v3.AggregateOperator) bool { return op != \"\" && op == v3.AggregateOperator(strings.ToLower(string(op))) && knownOps[op] }","tryCatchPattern":null,"preventionTips":["Always use the exported v3.AggregateOperator constants instead of raw strings","Build operator pickers in the UI from a list generated from the same constants"],"tags":["go","validation","enum","query-builder","signoz"],"backgroundTag":"invalid-enum-value","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}