{"record":{"id":"d685d8356cbfe882","repo":"SigNoz/signoz","slug":"invalid-aggregate-operator-w","errorCode":null,"errorMessage":"invalid aggregate operator: %w","messagePattern":"invalid aggregate operator: %w","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/model/v3/v3.go","lineNumber":357,"sourceCode":"\tif f.Limit > 1000 {\n\t\treturn fmt.Errorf(\"limit must be less than 1000\")\n\t}\n\n\tif f.ExistingFilterItems != nil {\n\t\tfor _, value := range f.ExistingFilterItems {\n\t\t\tif value.Key.Key == \"\" {\n\t\t\t\treturn fmt.Errorf(\"existingFilterItems must contain a valid key\")\n\t\t\t}\n\t\t}\n\t}\n\n\tif err := f.DataSource.Validate(); err != nil {\n\t\treturn fmt.Errorf(\"invalid data source: %w\", err)\n\t}\n\n\tif f.DataSource != DataSourceMetrics {\n\t\tif err := f.AggregateOperator.Validate(); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid aggregate operator: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\ntype AggregateAttributeResponse struct {\n\tAttributeKeys []AttributeKey `json:\"attributeKeys\"`\n}\n\ntype FilterAttributeKeyResponse struct {\n\tAttributeKeys []AttributeKey `json:\"attributeKeys\"`\n}\n\ntype AttributeKeyType string\n\nconst (\n\tAttributeKeyTypeUnspecified          AttributeKeyType = \"\"","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/model/v3/v3.go#L339-L375","documentation":"FilterAttributeValueRequest.Validate() requires a valid AggregateOperator whenever dataSource is NOT metrics (i.e. traces or logs), wrapping the operator validation error with this prefix. Traces/logs aggregation happens in ClickHouse, so an operator is mandatory there.","triggerScenarios":"Sending an attribute_value request with dataSource \"traces\" or \"logs\" while aggregateOperator is empty or invalid (e.g. \"P99\", \"rate\"). Metrics requests skip this check because metrics have their own aggregation semantics.","commonSituations":"Clients reusing a metrics-oriented payload for traces/logs and omitting the operator, or assuming the operator is optional for all data sources after seeing it skipped for metrics.","solutions":["For traces/logs requests always set aggregateOperator to a valid constant such as \"avg\", \"sum\", \"p95\"","Use the exported v3.AggregateOperator constants to avoid typos","Remember the asymmetry: metrics doesn't require it, traces/logs do"],"exampleFix":"// before\n{\"dataSource\":\"traces\",\"aggregateOperator\":\"\",...}\n\n// after\n{\"dataSource\":\"traces\",\"aggregateOperator\":\"avg\",...}","handlingStrategy":"validation","validationCode":"if req.DataSource != v3.DataSourceMetrics { if err := req.AggregateOperator.Validate(); err != nil { return fmt.Errorf(\"set a valid aggregateOperator for traces/logs: %w\", err) } }","typeGuard":"func traceRequestHasOperator(ds v3.DataSource, op v3.AggregateOperator) bool { return ds == v3.DataSourceMetrics || op != \"\" }","tryCatchPattern":null,"preventionTips":["Remember operator is mandatory for traces/logs, optional for metrics","Default the operator client-side (e.g. avg) for trace/log value lookups"],"tags":["go","validation","enum","aggregate-operator","signoz"],"backgroundTag":"invalid-enum-value","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}