SigNoz/signoz · error

query name is required

Error message

query name is required

What it means

BuilderQuery.Validate requires a non-empty QueryName; it is the map key and the identifier used in formulas.

Source

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

			return true
		}
	case DataSourceTraces, DataSourceLogs:
		if b.AggregateOperator.IsRateOperator() ||
			b.AggregateOperator == AggregateOperatorCount ||
			b.AggregateOperator == AggregateOperatorCountDistinct {
			return true
		}
	}
	return false
}

func (b *BuilderQuery) Validate(panelType PanelType) error {
	if b == nil {
		return nil
	}

	if b.QueryName == "" {
		return fmt.Errorf("query name is required")
	}

	// if expression is same as query name, it's a simple builder query and not a formula
	// formula involves more than one data source, aggregate operator, etc.
	if b.QueryName == b.Expression {
		if err := b.DataSource.Validate(); err != nil {
			return fmt.Errorf("data source is invalid: %w", err)
		}
		if b.DataSource == DataSourceMetrics {
			// if AggregateOperator is specified, then the request is using v3 payload
			// if b.AggregateOperator != "" && b.SpaceAggregation == SpaceAggregationUnspecified {
			// 	if err := b.AggregateOperator.Validate(); err != nil {
			// 		return fmt.Errorf("aggregate operator is invalid: %w", err)
			// 	}
			// } else {
			// 	// the time aggregation is not needed for percentile operators
			// 	if !IsPercentileOperator(b.SpaceAggregation) {
			// 		if err := b.TimeAggregation.Validate(); err != nil {

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Set queryName to a unique non-empty name like "A1"
  2. For formulas, ensure the expression references existing query names

Example fix

// before
{"A":{"expression":"A"}}
// after
{"A":{"queryName":"A","expression":"A"}}
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(q.QueryName) == "" { return errors.New("queryName is required") }

Type guard

func hasQueryName(q v3.BuilderQuery) bool { return strings.TrimSpace(q.QueryName) != "" }

Prevention

When it happens

Trigger: Posting a builder query whose queryName field is missing or empty string.

Common situations: Programmatically generating queries and forgetting to set queryName; copy-pasting JSON that dropped the field.

Understand the failure class

Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.

Related errors


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