SigNoz/signoz · error
invalid type for consumer group
Error message
invalid type for consumer group
What it means
Thrown by BuildClickHouseQuery in the Kafka messaging-queues integration when the query context is "consumer" but the required variable "consumer_group" is absent from messagingQueue.Variables. The function needs the consumer group name to build generateConsumerSQL, and cannot proceed without it. It is a caller-side contract violation, not a ClickHouse or Kafka broker error.
Source
Thrown at pkg/query-service/app/integrations/messagingQueues/kafka/translator.go:364
if !(queryContext == "consumer-throughput-details" ||
queryContext == "producer-throughput-details") {
partition, ok = messagingQueue.Variables["partition"]
if !ok {
return nil, fmt.Errorf("invalid type for Partition")
}
}
}
var query string
switch queryContext {
case "producer":
query = generateProducerSQL(start, end, topic, partition, queueType)
case "consumer":
consumerGroup, ok := messagingQueue.Variables["consumer_group"]
if !ok {
return nil, fmt.Errorf("invalid type for consumer group")
}
query = generateConsumerSQL(start, end, topic, partition, consumerGroup, queueType)
case "producer-topic-throughput":
query = generatePartitionLatencySQL(start, end, queueType)
case "consumer_partition_latency":
query = generateConsumerPartitionLatencySQL(start, end, topic, partition, queueType)
case "producer-throughput-details":
svcName, ok := messagingQueue.Variables["service_name"]
if !ok {
return nil, fmt.Errorf("invalid type for service")
}
query = generateProducerTopicLatencySQL(start, end, topic, svcName, queueType)
case "consumer-throughput-overview":
query = generateConsumerLatencySQL(start, end, queueType)
case "consumer-throughput-details":
svcName, ok := messagingQueue.Variables["service_name"]
if !ok {
return nil, fmt.Errorf("invalid type for service")View on GitHub (pinned to 5069bf80b0)
Solutions
- Ensure the request payload's Variables map contains a non-empty "consumer_group" entry (e.g. the consumer group selected in the UI filter).
- If you construct messagingQueue programmatically, set mq.Variables["consumer_group"] = groupName before calling BuildClickHouseQuery.
- Pre-validate required variables per queryContext before invoking the builder and return a clearer 400 to clients.
- Check for stale cached dashboard specs that reference old variable names after upgrading SigNoz.
Example fix
// before
mq := messagingqueues.MetricQueryRangeParams{ ... } // Variables has no consumer_group
query, err := BuildClickHouseQuery(ctx, mq, "consumer")
// after
mq.Variables["consumer_group"] = "my-consumer-group"
query, err := BuildClickHouseQuery(ctx, mq, "consumer") Defensive patterns
Strategy: validation
Validate before calling
func hasRequiredVars(vars map[string]interface{}, keys ...string) error {
for _, k := range keys {
if v, ok := vars[k]; !ok || v == nil || fmt.Sprint(v) == "" {
return fmt.Errorf("missing required variable %q", k)
}
}
return nil
}
// before BuildClickHouseQuery:
if queryContext == "consumer" {
if err := hasRequiredVars(mq.Variables, "consumer_group"); err != nil {
return http.StatusBadRequest, err
}
} Type guard
func isConsumerQueryReady(mq *messagingqueues.MetricQueryRangeParams) bool {
_, ok := mq.Variables["consumer_group"]
return ok
} Prevention
- Centralize a required-variables-per-queryContext map and validate before calling BuildClickHouseQuery.
- Write contract tests that every supported queryContext is invoked with its full variable set.
When it happens
Trigger: Calling BuildClickHouseQuery with queryContext == "consumer" while the messagingQueue.Variables map lacks a "consumer_group" key (the comma-separated ok assertion fails). Reached via onboardProducers, onboardConsumers, or BuildQueryRangeParams.
Common situations: Dashboard/widget payload for a Kafka consumer panel missing the consumer_group variable after a template change; API requests built from a config where the consumer group filter was renamed or omitted; upgrading between versions that changed the expected variable key.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/6e879b7dbbb730c3.
Report an issue: GitHub.