{"record":{"id":"007acbf26dc42967","repo":"SigNoz/signoz","slug":"aggregate-attribute-is-required","errorCode":null,"errorMessage":"aggregate attribute is required","messagePattern":"aggregate attribute is required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":1058,"sourceCode":"\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 {\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}","sourceCodeStart":1040,"sourceCodeEnd":1076,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L1040-L1076","documentation":"When the aggregate operator requires an attribute (e.g. rate, histogram, percentile ops on logs/traces) but AggregateAttribute is the zero AttributeKey, validation fails.","triggerScenarios":"A logs/traces builder query using an operator that needs an attribute (per RequireAttribute) with no aggregateAttribute set.","commonSituations":"Copying a metrics query shape to logs without specifying which attribute to aggregate over.","solutions":["Set aggregateAttribute with at least key and type/dataType","Or switch to an operator that doesn't require an attribute (noop/count)"],"exampleFix":"// before\n{\"aggregateOperator\":\"rate\"}\n// after\n{\"aggregateOperator\":\"rate\",\"aggregateAttribute\":{\"key\":\"durationNano\",\"type\":\"tag\",\"dataType\":\"float64\"}}","handlingStrategy":"validation","validationCode":"if q.AggregateOperator.RequireAttribute(q.DataSource) && q.AggregateAttribute == (v3.AttributeKey{}) {\n\treturn errors.New(\"aggregateAttribute required\")\n}","typeGuard":"func hasAggregateAttribute(q v3.BuilderQuery) bool { return q.AggregateAttribute != v3.AttributeKey{} }","tryCatchPattern":null,"preventionTips":["Pair attribute-requiring operators with an attribute in the query builder UI"],"tags":["go","required-field","aggregate-attribute"],"backgroundTag":"missing-required-field","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}