SigNoz/signoz · error
invalid reduce to operator: %s
Error message
invalid reduce to operator: %s
What it means
ReduceToOperator.Validate() rejects a reduce-to operator that is not one of the four supported values: last, sum, avg, min, max. The reduce-to operator controls how a time series is collapsed to a single value in builder queries (typically for table/value panels).
Source
Thrown at pkg/query-service/model/v3/v3.go:181
}
}
type ReduceToOperator string
const (
ReduceToOperatorLast ReduceToOperator = "last"
ReduceToOperatorSum ReduceToOperator = "sum"
ReduceToOperatorAvg ReduceToOperator = "avg"
ReduceToOperatorMin ReduceToOperator = "min"
ReduceToOperatorMax ReduceToOperator = "max"
)
func (r ReduceToOperator) Validate() error {
switch r {
case ReduceToOperatorLast, ReduceToOperatorSum, ReduceToOperatorAvg, ReduceToOperatorMin, ReduceToOperatorMax:
return nil
default:
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)View on GitHub (pinned to 5069bf80b0)
Solutions
- Use one of the exact constants: ReduceToOperatorLast, ReduceToOperatorSum, ReduceToOperatorAvg, ReduceToOperatorMin, ReduceToOperatorMax (strings "last", "sum", "avg", "min", "max")
- Substitute "avg" for mean/expected-value intents and "last" for gauge-style current-value intents
- Align frontend and backend versions so the reduce options offered in the UI match the server enum
Example fix
// before
bq.ReduceTo = v3.ReduceToOperator("mean")
// after
bq.ReduceTo = v3.ReduceToOperatorAvg Defensive patterns
Strategy: validation
Validate before calling
switch v3.ReduceToOperator(rt) { case v3.ReduceToOperatorLast, v3.ReduceToOperatorSum, v3.ReduceToOperatorAvg, v3.ReduceToOperatorMin, v3.ReduceToOperatorMax: default: return errors.New("invalid reduceTo") } Type guard
func isValidReduceTo(r v3.ReduceToOperator) bool { switch r { case v3.ReduceToOperatorLast, v3.ReduceToOperatorSum, v3.ReduceToOperatorAvg, v3.ReduceToOperatorMin, v3.ReduceToOperatorMax: return true }; return false } Prevention
- Map UI reduce options to the five enum values before building requests
- Default to ReduceToOperatorLast when the user hasn't chosen
When it happens
Trigger: Setting BuilderQuery.ReduceTo on a v3 builder query to anything other than "last", "sum", "avg", "min", or "max" — e.g. "median", "mean", "p50", or an empty string — then calling CompositeQuery.Validate() via a query API.
Common situations: UI version mismatch where the frontend offers a reduce function the backend doesn't support, hand-written API payloads using statistical terms not in the enum, or forgetting to set ReduceTo at all when it is required.
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
- invalid operator: %s
- invalid query type: %s
- invalid panel type: %s
- invalid tag type: %s
- invalid tag data type: %s
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/eb1581710ce2b6bd.
Report an issue: GitHub.