SigNoz/signoz · error

could not parse expr: %w

Error message

could not parse expr: %w

What it means

This is the lowest-level parse failure in the chain: parser.Parse (the expr-lang parser) could not build an AST for the given expression string. It is wrapped by logFieldsReferencedInExpr and surfaces up through fieldsReferencedInExprNotNilCheck and getOperators, so any operator whose `expr` fails to parse rejects the whole pipeline.

Source

Thrown at pkg/query-service/app/logparsingpipeline/pipelineBuilder.go:545

		memberRef := n.String()

		// coalesce ops end up as MemberNode right now for some reason.
		// ignore such member nodes.
		if strings.Contains(memberRef, "??") {
			return
		}

		if strings.HasPrefix(memberRef, "attributes") || strings.HasPrefix(memberRef, "resource") {
			v.referencedFields = append(v.referencedFields, memberRef)
		}
	}
}

func logFieldsReferencedInExpr(expr string) ([]string, error) {
	// parse abstract syntax tree for expr
	exprAst, err := parser.Parse(expr)
	if err != nil {
		return nil, fmt.Errorf("could not parse expr: %w", err)
	}

	// walk ast for expr to collect all member references.
	v := &logFieldsInExprExtractor{}
	ast.Walk(&exprAst.Node, v)

	return v.referencedFields, nil
}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Validate/parse the expr string with github.com/expr-lang/expr before submitting the pipeline
  2. Fix syntax errors (parens, operators, quoting)
  3. Keep expressions to arithmetic, comparison, and the documented function set

Example fix

// before
expr: "attributes.a ++ attributes.b"
// after
expr: "attributes.a + attributes.b"
Defensive patterns

Strategy: validation

Validate before calling

import "github.com/expr-lang/expr"
func checkExpr(s string) error {
  if _, err := expr.Compile(s); err != nil { return fmt.Errorf("expr does not compile: %w", err) }
  return nil
}

Type guard

func exprParses(s string) bool { _, err := parser.Parse(s); return err == nil }

Try / catch

Catch the API error, extract the inner parser message, and show it next to the expression field for correction (no retry — deterministic failure).

Prevention

When it happens

Trigger: Calling pipeline creation with an operator whose expr string is syntactically invalid: unbalanced parentheses, dangling operators, invalid tokens like "attributes.a ++ attributes.b", or an empty/whitespace-only expr.

Common situations: Typos in hand-authored pipeline JSON/YAML; expressions built via string concatenation that drop operands; using database-specific syntax (CAST, ::type) unsupported by expr-lang; version upgrades that changed the grammar.

Related errors


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