SigNoz/signoz · error

invalid query type: %s

Error message

invalid query type: %s

What it means

QueryType.Validate() fails when the composite query's type is not "builder" (QueryTypeBuilder), "clickhouse_sql" (QueryTypeClickHouseSQL), or "promql" (QueryTypePromQL). The query type selects which query payload branch the server interprets.

Source

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

		return fmt.Errorf("invalid reduce to operator: %s", r)
	}
}

type QueryType string

const (
	QueryTypeUnknown       QueryType = "unknown"
	QueryTypeBuilder       QueryType = "builder"
	QueryTypeClickHouseSQL QueryType = "clickhouse_sql"
	QueryTypePromQL        QueryType = "promql"
)

func (q QueryType) Validate() error {
	switch q {
	case QueryTypeBuilder, QueryTypeClickHouseSQL, QueryTypePromQL:
		return nil
	default:
		return fmt.Errorf("invalid query type: %s", q)
	}
}

type PanelType string

const (
	PanelTypeValue PanelType = "value"
	PanelTypeGraph PanelType = "graph"
	PanelTypeTable PanelType = "table"
	PanelTypeList  PanelType = "list"
	PanelTypeTrace PanelType = "trace"
)

func (p PanelType) Validate() error {
	switch p {
	case PanelTypeValue, PanelTypeGraph, PanelTypeTable, PanelTypeList, PanelTypeTrace:
		return nil
	default:

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Set queryType to exactly one of: "builder", "clickhouse_sql", "promql"
  2. Ensure the matching query payload (BuilderQueries / ClickHouseQueries / PromQueries) is present for that type
  3. Check the QueryType constants in v3.go for the canonical string values in your server version

Example fix

// before
{ "queryType": "sql", "clickHouseQueries": {...} }

// after
{ "queryType": "clickhouse_sql", "clickHouseQueries": {...} }
Defensive patterns

Strategy: validation

Validate before calling

qt := cq.QueryType
if qt != v3.QueryTypeBuilder && qt != v3.QueryTypeClickHouseSQL && qt != v3.QueryTypePromQL { return fmt.Errorf("bad queryType %q", qt) }

Type guard

func isValidQueryType(q v3.QueryType) bool { return q == v3.QueryTypeBuilder || q == v3.QueryTypeClickHouseSQL || q == v3.QueryTypePromQL }

Prevention

When it happens

Trigger: POSTing a query with compositeQuery.queryType set to something like "sql", "Builder", "prom", or omitted/empty, causing CompositeQuery.Validate() to propagate this error.

Common situations: Migrating from v2/v1 query APIs whose type names differ, typos in hand-built JSON, or a client using a newer/older queryType constant name than the deployed server.

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/0aa142ab988707da. Report an issue: GitHub.