SigNoz/signoz · error

having operator is invalid: %w

Error message

having operator is invalid: %w

What it means

Every entry in the Having clause must have an operator from the supported set (equals, not_equals, greater_than, ...); otherwise having.Operator.Validate fails.

Source

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

		}

		for _, groupBy := range b.GroupBy {
			if err := groupBy.Validate(); err != nil {
				return fmt.Errorf("group by is invalid %w", err)
			}
		}

		if b.DataSource == DataSourceMetrics && len(b.GroupBy) > 0 && b.SpaceAggregation == SpaceAggregationUnspecified {
			if b.AggregateOperator == AggregateOperatorNoOp || b.AggregateOperator == AggregateOperatorRate {
				return fmt.Errorf("group by requires aggregate operator other than noop or rate")
			}
		}
	}

	if b.Having != nil {
		for _, having := range b.Having {
			if err := having.Operator.Validate(); err != nil {
				return fmt.Errorf("having operator is invalid: %w", err)
			}
		}
	}

	for _, selectColumn := range b.SelectColumns {
		if err := selectColumn.Validate(); err != nil {
			return fmt.Errorf("select column is invalid %w", err)
		}
	}

	if b.Expression == "" {
		return fmt.Errorf("expression is required")
	}

	if len(b.Functions) > 0 {
		for _, function := range b.Functions {
			if err := function.Name.Validate(); err != nil {
				return fmt.Errorf("function name is invalid: %w", err)

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Use supported having operator constants (equals, not_equals, greater_than, greater_than_eq, less_than, less_than_eq, contains, not_contains, in, not_in)
  2. Check the wrapped error for the offending operator

Example fix

// before
"having":[{"columnName":"value","op":"gt","value":10}]
// after
"having":[{"columnName":"value","op":"greater_than","value":10}]
Defensive patterns

Strategy: type-guard

Validate before calling

for _, h := range q.Having { if err := h.Operator.Validate(); err != nil { return err } }

Type guard

func isValidHavingOp(op v3.FilterOperator) bool { return op.Validate() == nil }

Prevention

When it happens

Trigger: Sending having with operator "=" or "gt" instead of the enum names like "=" aliases not supported, e.g. "gt".

Common situations: Building alert/dashboard having clauses programmatically with shorthand operators.

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/a18fcc07debb6ce1. Report an issue: GitHub.