{"record":{"id":"50840d710a9a1385","repo":"t8y2/dbx","slug":"unexpected-management-api-response-for-node-listin","errorCode":null,"errorMessage":"Unexpected management API response for node listing","messagePattern":"Unexpected management API response for node listing","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rabbitmq/operations.go","lineNumber":1348,"sourceCode":"\tputIfPresent(info, \"totalExchanges\", nestedLongOrNull(overview, \"object_totals\", \"exchanges\"))\n\tputIfPresent(info, \"totalConnections\", nestedLongOrNull(overview, \"object_totals\", \"connections\"))\n\tputIfPresent(info, \"totalChannels\", nestedLongOrNull(overview, \"object_totals\", \"channels\"))\n\tputIfPresent(info, \"totalConsumers\", nestedLongOrNull(overview, \"object_totals\", \"consumers\"))\n\treturn info\n}\n\nfunc (s *server) listNodes(params jsonObject) (any, error) {\n\tconnection, err := s.requireConnectionConfig(params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tnodes, err := managementGet(connection, \"/api/nodes\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tarray, ok := nodes.([]any)\n\tif !ok {\n\t\treturn nil, errors.New(\"Unexpected management API response for node listing\")\n\t}\n\tresult := make([]jsonObject, 0, len(array))\n\tfor _, value := range array {\n\t\tnode, ok := value.(map[string]any)\n\t\tif ok {\n\t\t\tresult = append(result, nodeInfoFromJSON(jsonObject(node)))\n\t\t}\n\t}\n\tsort.SliceStable(result, func(left, right int) bool {\n\t\treturn stringOrEmpty(result[left], \"name\") < stringOrEmpty(result[right], \"name\")\n\t})\n\treturn jsonObject{\"nodes\": result}, nil\n}\n\nfunc nodeInfoFromJSON(node jsonObject) jsonObject {\n\tinfo := jsonObject{\n\t\t\"name\":    stringOrEmpty(node, \"name\"),\n\t\t\"running\": boolOrDefault(node, \"running\", false),","sourceCodeStart":1330,"sourceCodeEnd":1366,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rabbitmq/operations.go#L1330-L1366","documentation":"listNodes calls GET /api/nodes and expects a JSON array of node objects. If the response is not an array, the library throws this error. This protects callers from processing a malformed or unexpected management API response (e.g. an error object instead of the node list).","triggerScenarios":"Management API returns a JSON object (e.g. {\"error\":\"...\"}) or scalar instead of an array for /api/nodes.","commonSituations":"Proxy returning an error object; authentication failure producing a non-array body; management plugin version mismatch changing the response envelope; hitting the wrong endpoint path.","solutions":["curl -u user:pass http://host:15672/api/nodes and confirm the body is a JSON array","Check credentials and that the response is not an auth/error object","Verify the management plugin is enabled (rabbitmq-plugins enable rabbitmq_management)","Upgrade/align driver with the RabbitMQ server version"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"const res = await fetch(managementUrl + \"/api/nodes\", { headers: authHeader });\nconst body = await res.json();\nif (!Array.isArray(body)) throw new Error(\"/api/nodes did not return an array\");","typeGuard":"function isNodeList(v) { return Array.isArray(v) && v.every(n => n != null && typeof n === \"object\"); }","tryCatchPattern":"try { await agent.dispatch(\"listNodes\", {}); } catch (e) { if (/Unexpected management API response/.test(e.message)) { /* verify /api/nodes returns a JSON array */ } else throw e; }","preventionTips":["Verify /api/nodes with curl before automating","Ensure the management plugin is enabled","Check for auth middleware returning error objects","Pin compatible RabbitMQ/driver versions"],"tags":["rabbitmq","management-api","unexpected-response","http"],"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"}