{"record":{"id":"9a6b0fd19625f5f2","repo":"SigNoz/signoz","slug":"aggregate-operator-is-invalid-w","errorCode":null,"errorMessage":"aggregate operator is invalid: %w","messagePattern":"aggregate operator is invalid: %w","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":1054,"sourceCode":"\t\t\t// if b.AggregateOperator != \"\" && b.SpaceAggregation == SpaceAggregationUnspecified {\n\t\t\t// \tif err := b.AggregateOperator.Validate(); err != nil {\n\t\t\t// \t\treturn fmt.Errorf(\"aggregate operator is invalid: %w\", err)\n\t\t\t// \t}\n\t\t\t// } else {\n\t\t\t// \t// the time aggregation is not needed for percentile operators\n\t\t\t// \tif !IsPercentileOperator(b.SpaceAggregation) {\n\t\t\t// \t\tif err := b.TimeAggregation.Validate(); err != nil {\n\t\t\t// \t\t\treturn fmt.Errorf(\"time aggregation is invalid: %w\", err)\n\t\t\t// \t\t}\n\t\t\t// \t}\n\n\t\t\t// \tif err := b.SpaceAggregation.Validate(); err != nil {\n\t\t\t// \t\treturn fmt.Errorf(\"space aggregation is invalid: %w\", err)\n\t\t\t// \t}\n\t\t\t// }\n\t\t} else {\n\t\t\tif err := b.AggregateOperator.Validate(); err != nil {\n\t\t\t\treturn fmt.Errorf(\"aggregate operator is invalid: %w\", err)\n\t\t\t}\n\t\t}\n\t\tif b.AggregateAttribute == (AttributeKey{}) && b.AggregateOperator.RequireAttribute(b.DataSource) {\n\t\t\treturn fmt.Errorf(\"aggregate attribute is required\")\n\t\t}\n\t}\n\n\tif b.Filters != nil {\n\t\tif err := b.Filters.Validate(); err != nil {\n\t\t\treturn fmt.Errorf(\"filters are invalid: %w\", err)\n\t\t}\n\t}\n\tif b.GroupBy != nil {\n\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 {","sourceCodeStart":1036,"sourceCodeEnd":1072,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L1036-L1072","documentation":"For simple builder queries on non-metrics data sources (logs/traces), AggregateOperator.Validate must pass; the value must be in the allowed operator set.","triggerScenarios":"Logs/traces builder query with an aggregateOperator like \"percentile\" or an empty/unknown string.","commonSituations":"Applying metrics-only operators to logs queries, or old v2 payloads with renamed operators.","solutions":["Use a valid AggregateOperator constant for the data source","For metrics with v3 payload, prefer setting spaceAggregation/timeAggregation instead","Check operator name spelling (e.g. \"noop\" not \"no_op\")"],"exampleFix":"// before\n{\"dataSource\":\"logs\",\"aggregateOperator\":\"percentile\"}\n// after\n{\"dataSource\":\"logs\",\"aggregateOperator\":\"avg\"}","handlingStrategy":"validation","validationCode":"if q.DataSource != v3.DataSourceMetrics { if err := q.AggregateOperator.Validate(); err != nil { return err } }","typeGuard":"func isValidAggOp(op v3.AggregateOperator) bool { return op.Validate() == nil }","tryCatchPattern":null,"preventionTips":["Prefer v3 space/time aggregation fields for metrics"],"tags":["go","enum-validation","aggregate-operator"],"backgroundTag":"invalid-enum-value","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}