SigNoz/signoz · error

prom query %s is invalid: %w

Error message

prom query %s is invalid: %w

What it means

Thrown by CompositeQuery.Validate when a PromQueries entry fails PromQuery.Validate. The %s is the query name key; %w wraps the inner error such as a missing PromQL expression.

Source

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

		for name, query := range c.BuilderQueries {
			if err := query.Validate(c.PanelType); err != nil {
				return fmt.Errorf("builder query %s is invalid: %w", name, err)
			}
		}
	}

	if c.QueryType == QueryTypeClickHouseSQL {
		for name, query := range c.ClickHouseQueries {
			if err := query.Validate(); err != nil {
				return fmt.Errorf("clickhouse query %s is invalid: %w", name, err)
			}
		}
	}

	if c.QueryType == QueryTypePromQL {
		for name, query := range c.PromQueries {
			if err := query.Validate(); err != nil {
				return fmt.Errorf("prom query %s is invalid: %w", name, err)
			}
		}
	}

	if err := c.PanelType.Validate(); err != nil {
		return fmt.Errorf("panel type is invalid: %w", err)
	}

	if err := c.QueryType.Validate(); err != nil {
		return fmt.Errorf("query type is invalid: %w", err)
	}

	return nil
}

type Temporality string

const (

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Check the wrapped error for the exact missing field
  2. Ensure each PromQueries entry has a non-empty query string
  3. Use the /api/v1/query API of the query service to smoke-test the payload before saving the dashboard

Example fix

// before
{"queryType":"promql","promQueries":{"A":{}}}
// after
{"queryType":"promql","promQueries":{"A":{"query":"up"}}}
Defensive patterns

Strategy: validation

Validate before calling

for name, q := range composite.PromQueries {
	if strings.TrimSpace(q.Query) == "" { return fmt.Errorf("prom query %s: empty query", name) }
}

Type guard

func hasPromQuery(q v3.PromQuery) bool { return strings.TrimSpace(q.Query) != "" }

Try / catch

if err := composite.Validate(); err != nil { return apiError(400, err) }

Prevention

When it happens

Trigger: Submitting queryType=promql with a PromQueries entry whose query/expression is empty or otherwise invalid.

Common situations: PromQL panels migrated from Prometheus, or programmatically generated payloads where the expression field was never populated.

Related errors


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