SigNoz/signoz · error

expression is required

Error message

expression is required

What it means

BuilderQuery.Validate requires a non-empty Expression; for simple queries it equals the query name, for formulas it is an expression over query names (e.g. "A + B").

Source

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

		}
	}

	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)
			}
			if function.Name == FunctionNameTimeShift {
				if len(function.Args) == 0 {
					return fmt.Errorf("timeShiftBy param missing in query")
				}
				_, ok := function.Args[0].(float64)
				if !ok {
					// if string, attempt to convert to float
					timeShiftBy, err := strconv.ParseFloat(function.Args[0].(string), 64)
					if err != nil {
						return fmt.Errorf("timeShiftBy param should be a number")
					}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Set expression to the query name for simple queries ("A")
  2. For formulas, set an expression referencing other query names, e.g. "A/B"

Example fix

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

Strategy: validation

Validate before calling

if strings.TrimSpace(q.Expression) == "" { return errors.New("expression required") }

Type guard

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

Prevention

When it happens

Trigger: Sending a builder query with expression omitted or empty string.

Common situations: Programmatic payload construction forgetting the expression field, or partial JSON edits.

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