t8y2/dbx · error

Unexpected management API response for queue details

Error message

Unexpected management API response for queue details

What it means

listConsumers fetches queue details from the management API and expects the response to decode into a JSON object (map). If the payload isn't an object — e.g. a 404 error body, a plain string, or an array — the type assertion fails and this error is thrown.

Source

Thrown at agents/drivers/rabbitmq/operations.go:267

func (s *server) listConsumers(params jsonObject) (any, error) {
	connection, err := s.requireConnectionConfig(params)
	if err != nil {
		return nil, err
	}
	name, err := queueName(params)
	if err != nil {
		return nil, err
	}
	vhost := effectiveVhost(params, connection)
	queue, err := managementGet(connection,
		"/api/queues/"+urlEncodeVhost(vhost)+"/"+urlEncodePathSegment(name))
	if err != nil {
		return nil, err
	}
	info, ok := queue.(map[string]any)
	if !ok {
		return nil, errors.New("Unexpected management API response for queue details")
	}
	return jsonObject{"consumers": consumersFromQueueInfo(jsonObject(info))}, nil
}

func consumersFromQueueInfo(info jsonObject) []jsonObject {
	details := arrayOrNil(info, "consumer_details")
	consumers := make([]jsonObject, 0, len(details))
	for _, value := range details {
		consumerMap, ok := value.(map[string]any)
		if !ok {
			continue
		}
		consumer := jsonObject(consumerMap)
		channelName := ""
		if channelDetails := objectOrNil(consumer, "channel_details"); channelDetails != nil {
			channelName = stringOrEmpty(channelDetails, "name")
		}
		entry := jsonObject{

View on GitHub (pinned to c0390bff16)

Solutions

  1. Verify the queue exists and the vhost is correct before listing consumers
  2. Check the management API response manually (curl /api/queues/{vhost}/{name}) to see the actual payload
  3. Enable management plugin and confirm the user has permissions to view the queue

Example fix

// before
agent.Call("mq_list_consumers", map[string]any{"topic": "ordres", "virtual_host": "prod"}) // typo: queue missing
// after
// ensure topic exists
agent.Call("mq_create_topic", map[string]any{"topic": "orders", "virtual_host": "prod"})
agent.Call("mq_list_consumers", map[string]any{"topic": "orders", "virtual_host": "prod"})
Defensive patterns

Strategy: type-guard

Validate before calling

// verify queue exists first
_, err := agent.Call("mq_get_topic_stats", map[string]any{"topic": name, "virtual_host": vhost})
if err != nil { return fmt.Errorf("queue %s/%s not found before listing consumers", vhost, name) }

Type guard

func isQueueDetails(resp any) bool {
	_, ok := resp.(map[string]any)
	return ok
}

Try / catch

_, err := agent.Call("mq_list_consumers", params)
if err != nil && strings.Contains(err.Error(), "Unexpected management API response") {
	return fmt.Errorf("queue %v/%v missing or management API returned non-object payload", params["virtual_host"], params["topic"])
}

Prevention

When it happens

Trigger: Calling mq_list_consumers (or the integration test path) when the management API response for /api/queues/{vhost}/{name} is not a map — typically the queue doesn't exist (404 body), wrong vhost, or the management API returned an unexpected/error payload.

Common situations: Queue deleted between listing and consumer lookup; vhost URL-encoding mismatch targeting the wrong path; management plugin version returning a different error shape; typo'd queue name.

Related errors


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/a14571baca9ad69b. Report an issue: GitHub.