{"record":{"id":"6e879b7dbbb730c3","repo":"SigNoz/signoz","slug":"invalid-type-for-consumer-group","errorCode":null,"errorMessage":"invalid type for consumer group","messagePattern":"invalid type for consumer group","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/query-service/app/integrations/messagingQueues/kafka/translator.go","lineNumber":364,"sourceCode":"\t\tif !(queryContext == \"consumer-throughput-details\" ||\n\t\t\tqueryContext == \"producer-throughput-details\") {\n\n\t\t\tpartition, ok = messagingQueue.Variables[\"partition\"]\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid type for Partition\")\n\t\t\t}\n\t\t}\n\t}\n\n\tvar query string\n\n\tswitch queryContext {\n\tcase \"producer\":\n\t\tquery = generateProducerSQL(start, end, topic, partition, queueType)\n\tcase \"consumer\":\n\t\tconsumerGroup, ok := messagingQueue.Variables[\"consumer_group\"]\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"invalid type for consumer group\")\n\t\t}\n\t\tquery = generateConsumerSQL(start, end, topic, partition, consumerGroup, queueType)\n\tcase \"producer-topic-throughput\":\n\t\tquery = generatePartitionLatencySQL(start, end, queueType)\n\tcase \"consumer_partition_latency\":\n\t\tquery = generateConsumerPartitionLatencySQL(start, end, topic, partition, queueType)\n\tcase \"producer-throughput-details\":\n\t\tsvcName, ok := messagingQueue.Variables[\"service_name\"]\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"invalid type for service\")\n\t\t}\n\t\tquery = generateProducerTopicLatencySQL(start, end, topic, svcName, queueType)\n\tcase \"consumer-throughput-overview\":\n\t\tquery = generateConsumerLatencySQL(start, end, queueType)\n\tcase \"consumer-throughput-details\":\n\t\tsvcName, ok := messagingQueue.Variables[\"service_name\"]\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"invalid type for service\")","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/SigNoz/signoz/blob/5069bf80b08f1f00d7e014eccc09902f9871004f/pkg/query-service/app/integrations/messagingQueues/kafka/translator.go#L346-L382","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nmq := messagingqueues.MetricQueryRangeParams{ ... } // Variables has no consumer_group\nquery, err := BuildClickHouseQuery(ctx, mq, \"consumer\")\n\n// after\nmq.Variables[\"consumer_group\"] = \"my-consumer-group\"\nquery, err := BuildClickHouseQuery(ctx, mq, \"consumer\")","handlingStrategy":"validation","validationCode":"func hasRequiredVars(vars map[string]interface{}, keys ...string) error {\n\tfor _, k := range keys {\n\t\tif v, ok := vars[k]; !ok || v == nil || fmt.Sprint(v) == \"\" {\n\t\t\treturn fmt.Errorf(\"missing required variable %q\", k)\n\t\t}\n\t}\n\treturn nil\n}\n// before BuildClickHouseQuery:\nif queryContext == \"consumer\" {\n\tif err := hasRequiredVars(mq.Variables, \"consumer_group\"); err != nil {\n\t\treturn http.StatusBadRequest, err\n\t}\n}","typeGuard":"func isConsumerQueryReady(mq *messagingqueues.MetricQueryRangeParams) bool {\n\t_, ok := mq.Variables[\"consumer_group\"]\n\treturn ok\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["kafka","clickhouse","query-builder","missing-variable","messaging-queues"],"backgroundTag":"missing-required-parameter","analyzedSha":"5069bf80b08f1f00d7e014eccc09902f9871004f","analyzedAt":"2026-08-28T06:22:12.824Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}