SigNoz/signoz · error

invalid aggregate operator: %w

Error message

invalid aggregate operator: %w

What it means

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.

Source

Thrown at pkg/query-service/model/v3/v3.go:357

	if f.Limit > 1000 {
		return fmt.Errorf("limit must be less than 1000")
	}

	if f.ExistingFilterItems != nil {
		for _, value := range f.ExistingFilterItems {
			if value.Key.Key == "" {
				return fmt.Errorf("existingFilterItems must contain a valid key")
			}
		}
	}

	if err := f.DataSource.Validate(); err != nil {
		return fmt.Errorf("invalid data source: %w", err)
	}

	if f.DataSource != DataSourceMetrics {
		if err := f.AggregateOperator.Validate(); err != nil {
			return fmt.Errorf("invalid aggregate operator: %w", err)
		}
	}

	return nil
}

type AggregateAttributeResponse struct {
	AttributeKeys []AttributeKey `json:"attributeKeys"`
}

type FilterAttributeKeyResponse struct {
	AttributeKeys []AttributeKey `json:"attributeKeys"`
}

type AttributeKeyType string

const (
	AttributeKeyTypeUnspecified          AttributeKeyType = ""

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. For traces/logs requests always set aggregateOperator to a valid constant such as "avg", "sum", "p95"
  2. Use the exported v3.AggregateOperator constants to avoid typos
  3. Remember the asymmetry: metrics doesn't require it, traces/logs do

Example fix

// before
{"dataSource":"traces","aggregateOperator":"",...}

// after
{"dataSource":"traces","aggregateOperator":"avg",...}
Defensive patterns

Strategy: validation

Validate before calling

if req.DataSource != v3.DataSourceMetrics { if err := req.AggregateOperator.Validate(); err != nil { return fmt.Errorf("set a valid aggregateOperator for traces/logs: %w", err) } }

Type guard

func traceRequestHasOperator(ds v3.DataSource, op v3.AggregateOperator) bool { return ds == v3.DataSourceMetrics || op != "" }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/d685d8356cbfe882. Report an issue: GitHub.