{"record":{"id":"43dd026f7475f298","repo":"SigNoz/signoz","slug":"group-by-requires-aggregate-operator-other-than-no","errorCode":null,"errorMessage":"group by requires aggregate operator other than noop or rate","messagePattern":"group by requires aggregate operator other than noop or rate","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":1086,"sourceCode":"\t\t// if len(b.GroupBy) > 0 && panelType == PanelTypeList {\n\t\t// \treturn fmt.Errorf(\"group by is not supported for list panel type\")\n\t\t// }\n\n\t\tif panelType == PanelTypeValue && len(b.GroupBy) > 0 {\n\t\t\tif err := b.SecondaryAggregation.Validate(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"series aggregation is required for value type panel with group by: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\tfor _, groupBy := range b.GroupBy {\n\t\t\tif err := groupBy.Validate(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"group by is invalid %w\", err)\n\t\t\t}\n\t\t}\n\n\t\tif b.DataSource == DataSourceMetrics && len(b.GroupBy) > 0 && b.SpaceAggregation == SpaceAggregationUnspecified {\n\t\t\tif b.AggregateOperator == AggregateOperatorNoOp || b.AggregateOperator == AggregateOperatorRate {\n\t\t\t\treturn fmt.Errorf(\"group by requires aggregate operator other than noop or rate\")\n\t\t\t}\n\t\t}\n\t}\n\n\tif b.Having != nil {\n\t\tfor _, having := range b.Having {\n\t\t\tif err := having.Operator.Validate(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"having operator is invalid: %w\", err)\n\t\t\t}\n\t\t}\n\t}\n\n\tfor _, selectColumn := range b.SelectColumns {\n\t\tif err := selectColumn.Validate(); err != nil {\n\t\t\treturn fmt.Errorf(\"select column is invalid %w\", err)\n\t\t}\n\t}\n","sourceCodeStart":1068,"sourceCodeEnd":1104,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L1068-L1104","documentation":"On metrics queries with group by and no space aggregation specified (legacy v3 payload), the aggregate operator cannot be noop or rate because grouping requires a real aggregate function.","triggerScenarios":"dataSource=metrics, groupBy non-empty, spaceAggregation unspecified, aggregateOperator=noop or rate.","commonSituations":"Legacy v3 payloads that rely on aggregateOperator; migration to spaceAggregation-based payloads fixes it.","solutions":["Set spaceAggregation (and timeAggregation) to use the newer v3 metrics payload","Or change aggregateOperator to sum/avg/min/max etc. when grouping"],"exampleFix":"// before\n{\"dataSource\":\"metrics\",\"aggregateOperator\":\"rate\",\"groupBy\":[{\"key\":\"service_name\"}]}\n// after\n{\"dataSource\":\"metrics\",\"timeAggregation\":\"rate\",\"spaceAggregation\":\"sum\",\"groupBy\":[{\"key\":\"service_name\"}]}","handlingStrategy":"validation","validationCode":"if q.DataSource == v3.DataSourceMetrics && len(q.GroupBy) > 0 && q.SpaceAggregation == v3.SpaceAggregationUnspecified {\n\tif q.AggregateOperator == v3.AggregateOperatorNoOp || q.AggregateOperator == v3.AggregateOperatorRate {\n\t\treturn errors.New(\"group by needs a real aggregate operator\")\n\t}\n}","typeGuard":"func metricsGroupBySafe(q v3.BuilderQuery) bool { return !(len(q.GroupBy) > 0 && q.SpaceAggregation == v3.SpaceAggregationUnspecified && (q.AggregateOperator == v3.AggregateOperatorNoOp || q.AggregateOperator == v3.AggregateOperatorRate)) }","tryCatchPattern":null,"preventionTips":["Migrate metrics payloads to time/space aggregation model"],"tags":["go","metrics","aggregate-operator"],"backgroundTag":"query-payload-validation-failed","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}