{"record":{"id":"a14571baca9ad69b","repo":"t8y2/dbx","slug":"unexpected-management-api-response-for-queue-detai","errorCode":null,"errorMessage":"Unexpected management API response for queue details","messagePattern":"Unexpected management API response for queue details","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rabbitmq/operations.go","lineNumber":267,"sourceCode":"\nfunc (s *server) listConsumers(params jsonObject) (any, error) {\n\tconnection, err := s.requireConnectionConfig(params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tname, err := queueName(params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvhost := effectiveVhost(params, connection)\n\tqueue, err := managementGet(connection,\n\t\t\"/api/queues/\"+urlEncodeVhost(vhost)+\"/\"+urlEncodePathSegment(name))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tinfo, ok := queue.(map[string]any)\n\tif !ok {\n\t\treturn nil, errors.New(\"Unexpected management API response for queue details\")\n\t}\n\treturn jsonObject{\"consumers\": consumersFromQueueInfo(jsonObject(info))}, nil\n}\n\nfunc consumersFromQueueInfo(info jsonObject) []jsonObject {\n\tdetails := arrayOrNil(info, \"consumer_details\")\n\tconsumers := make([]jsonObject, 0, len(details))\n\tfor _, value := range details {\n\t\tconsumerMap, ok := value.(map[string]any)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\t\tconsumer := jsonObject(consumerMap)\n\t\tchannelName := \"\"\n\t\tif channelDetails := objectOrNil(consumer, \"channel_details\"); channelDetails != nil {\n\t\t\tchannelName = stringOrEmpty(channelDetails, \"name\")\n\t\t}\n\t\tentry := jsonObject{","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rabbitmq/operations.go#L249-L285","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the queue exists and the vhost is correct before listing consumers","Check the management API response manually (curl /api/queues/{vhost}/{name}) to see the actual payload","Enable management plugin and confirm the user has permissions to view the queue"],"exampleFix":"// before\nagent.Call(\"mq_list_consumers\", map[string]any{\"topic\": \"ordres\", \"virtual_host\": \"prod\"}) // typo: queue missing\n// after\n// ensure topic exists\nagent.Call(\"mq_create_topic\", map[string]any{\"topic\": \"orders\", \"virtual_host\": \"prod\"})\nagent.Call(\"mq_list_consumers\", map[string]any{\"topic\": \"orders\", \"virtual_host\": \"prod\"})","handlingStrategy":"type-guard","validationCode":"// verify queue exists first\n_, err := agent.Call(\"mq_get_topic_stats\", map[string]any{\"topic\": name, \"virtual_host\": vhost})\nif err != nil { return fmt.Errorf(\"queue %s/%s not found before listing consumers\", vhost, name) }","typeGuard":"func isQueueDetails(resp any) bool {\n\t_, ok := resp.(map[string]any)\n\treturn ok\n}","tryCatchPattern":"_, err := agent.Call(\"mq_list_consumers\", params)\nif err != nil && strings.Contains(err.Error(), \"Unexpected management API response\") {\n\treturn fmt.Errorf(\"queue %v/%v missing or management API returned non-object payload\", params[\"virtual_host\"], params[\"topic\"])\n}","preventionTips":["Check queue existence before consumer lookups","Double-check vhost names and URL-encoding of special characters","Confirm the management user has read permissions on the queue"],"tags":["rabbitmq","management-api","unexpected-response"],"backgroundTag":"unexpected-api-response","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}