SigNoz/signoz · error

group by is invalid %w

Error message

group by is invalid %w

What it means

Each group-by entry is validated via AttributeKey.Validate; failure means the key is empty or the entry is otherwise malformed.

Source

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

	if b.Filters != nil {
		if err := b.Filters.Validate(); err != nil {
			return fmt.Errorf("filters are invalid: %w", err)
		}
	}
	if b.GroupBy != nil {
		// if len(b.GroupBy) > 0 && panelType == PanelTypeList {
		// 	return fmt.Errorf("group by is not supported for list panel type")
		// }

		if panelType == PanelTypeValue && len(b.GroupBy) > 0 {
			if err := b.SecondaryAggregation.Validate(); err != nil {
				return fmt.Errorf("series aggregation is required for value type panel with group by: %w", err)
			}
		}

		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)
			}
		}
	}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Filter out empty selections before adding to groupBy
  2. Ensure each groupBy item has a non-empty key (and type/dataType where applicable)

Example fix

// before
"groupBy":[{"key":""}]
// after
"groupBy":[{"key":"service.name"}]
Defensive patterns

Strategy: validation

Validate before calling

for _, g := range q.GroupBy { if strings.TrimSpace(g.Key) == "" { return errors.New("groupBy key required") } }

Type guard

func hasValidGroupBy(gb []v3.AttributeKey) bool { for _, g := range gb { if g.Key == "" { return false } }; return true }

Prevention

When it happens

Trigger: A groupBy array containing an element with an empty key or missing required attribute fields.

Common situations: Dynamically building groupBy from user selections where an empty selection slips through.

Related errors


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