SigNoz/signoz · error

data source is invalid: %w

Error message

data source is invalid: %w

What it means

For a simple (non-formula) builder query (QueryName == Expression), the DataSource must be a valid value (metrics, logs, traces). %w wraps DataSource.Validate.

Source

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

		}
	}
	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 {
			// 			return fmt.Errorf("time aggregation is invalid: %w", err)
			// 		}
			// 	}

			// 	if err := b.SpaceAggregation.Validate(); err != nil {
			// 		return fmt.Errorf("space aggregation is invalid: %w", err)
			// 	}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Set dataSource to "metrics", "logs", or "traces" exactly
  2. If the query is a pure formula, make sure expression differs from queryName so validation is skipped

Example fix

// before
{"dataSource":"metric"}
// after
{"dataSource":"metrics"}
Defensive patterns

Strategy: type-guard

Validate before calling

if q.QueryName == q.Expression { if err := q.DataSource.Validate(); err != nil { return err } }

Type guard

func isValidDataSource(d v3.DataSource) bool { return d.Validate() == nil }

Prevention

When it happens

Trigger: Sending a builder query with dataSource "" or an unrecognized string like "metric".

Common situations: Omitting dataSource in hand-built payloads or using singular forms ("metric"/"log").

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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