t8y2/dbx · error
topic is required when producerGroup is specified
Error message
topic is required when producerGroup is specified
What it means
listProducers can query producer connections either by topic or by producerGroup, but the admin API ExamineProducerConnectionInfo always needs both. When 'producerGroup' (alias 'group') is specified without 'topic', the driver refuses the call with 'topic is required when producerGroup is specified'. This is a precondition check before the broker call.
Source
Thrown at agents/drivers/rocketmq/messages.go:39
type messageQueueTarget struct {
BrokerName string
Address string
QueueID int
}
func (a *rocketMQAgent) listProducers(params map[string]any) (any, error) {
client, config, err := a.requireClient()
if err != nil {
return nil, err
}
ctx, cancel := context.WithTimeout(context.Background(), config.RequestTimeout)
defer cancel()
topic := stringValue(params, "topic")
producerGroup := stringValue(params, "producerGroup", "group")
rows := make([]map[string]any, 0)
if producerGroup != "" {
if topic == "" {
return nil, fmt.Errorf("topic is required when producerGroup is specified")
}
connection, queryErr := client.ExamineProducerConnectionInfo(ctx, producerGroup, topic)
if queryErr != nil {
return nil, queryErr
}
for index, connectionInfo := range connection.ConnectionSet {
rows = append(rows, producerRow(int64(index+1), producerGroup, connectionInfo))
}
return map[string]any{"producers": rows}, nil
}
addresses := make([]string, 0)
if topic != "" {
stats, statsErr := a.examineTopicStats(ctx, client, topic)
if statsErr != nil {
return nil, statsErr
}
hasMessages := falseView on GitHub (pinned to c0390bff16)
Solutions
- Pass the 'topic' alongside 'producerGroup' — the query is per (group, topic) pair.
- If you need all topics for a group, first list topics (topic list operation) then call listProducers per topic.
- Remove 'producerGroup' entirely to fall back to topic-only listing, if that matches your intent.
- Ensure the topic value isn't an empty string from upstream config.
Example fix
// before
rows, err := agent.ListProducers(ctx, map[string]any{"producerGroup": "PID_demo"})
// after
rows, err := agent.ListProducers(ctx, map[string]any{"producerGroup": "PID_demo", "topic": "demo-topic"}) Defensive patterns
Strategy: validation
Validate before calling
group, _ := params["producerGroup"].(string)
if group == "" { group, _ = params["group"].(string) }
topic, _ := params["topic"].(string)
if group != "" && topic == "" {
return errors.New("topic is required when producerGroup is specified")
} Type guard
func producerQueryValid(params map[string]any) bool {
g := coalesce(params, "producerGroup", "group")
t := coalesce(params, "topic")
return g == "" || t != ""
} Try / catch
rows, err := agent.ListProducers(ctx, params)
if err != nil && strings.Contains(err.Error(), "topic is required when producerGroup") {
// fix input: enumerate topics first, then query per (group, topic)
} Prevention
- Remember ExamineProducerConnectionInfo is always (group, topic)-scoped; never send group alone.
- To enumerate all producers of a group, loop over the topic list.
- Make 'topic' a required field in forms/APIs that accept producerGroup.
- Guard against empty-string topics from optional UI inputs.
When it happens
Trigger: Calling the listProducers dispatch operation with {"producerGroup": "PID_xxx"} and no 'topic' key (or an empty topic), intending to enumerate all topics for a group.
Common situations: Assuming group-only listing is supported (like consumer group inspection); building a UI where the topic field is optional; migrating code from another admin tool that supported group-only queries.
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
- %s is required
- <label> are required
- agentSessionId is required
- agentSessionId is required
- user is required
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/dc94e8ea56c01055.
Report an issue: GitHub.