{"record":{"id":"cd43730e556cbca4","repo":"t8y2/dbx","slug":"all-vhosts-is-only-supported-for-list-operations","errorCode":null,"errorMessage":"all_vhosts is only supported for list operations","messagePattern":"all_vhosts is only supported for list operations","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rabbitmq/main.go","lineNumber":143,"sourceCode":"\t\t\tresponse.Error = &rpcError{Code: -1, Message: normalizeErrorMessage(err)}\n\t\t\treturn response, false\n\t\t}\n\t\tif object, ok := decoded.(map[string]any); ok {\n\t\t\tparams = jsonObject(object)\n\t\t}\n\t}\n\tresult, shutdown, err := s.dispatch(request.Method, params)\n\tif err != nil {\n\t\tresponse.Error = &rpcError{Code: -1, Message: normalizeErrorMessage(err)}\n\t\treturn response, false\n\t}\n\tresponse.Result = result\n\treturn response, shutdown\n}\n\nfunc (s *server) dispatch(method string, params jsonObject) (any, bool, error) {\n\tif _, unsupported := allVhostsUnsupportedMethods[method]; unsupported && allVhostsRequested(params) {\n\t\treturn nil, false, errors.New(\"all_vhosts is only supported for list operations\")\n\t}\n\tswitch method {\n\tcase \"handshake\":\n\t\treturn handshakeResult{protocolVersion, agentProtocolVersion, capabilities}, false, nil\n\tcase \"connect\":\n\t\tresult, err := s.connect(params)\n\t\treturn result, false, err\n\tcase \"test_connection\":\n\t\tresult, err := s.testConnection(params)\n\t\treturn result, false, err\n\tcase \"disconnect\":\n\t\ts.closeClients()\n\t\treturn okResult(), false, nil\n\tcase \"shutdown\":\n\t\ts.closeClients()\n\t\treturn okResult(), true, nil\n\tcase \"mq_list_topics\":\n\t\tresult, err := s.listTopics(params)","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rabbitmq/main.go#L125-L161","documentation":"When the request params enable all_vhosts mode, only list-style methods may use it; the driver rejects non-list methods before dispatching. This prevents applying a single operation across every vhost, which the underlying management APIs don't support per-method.","triggerScenarios":"Calling any method in allVhostsUnsupportedMethods (e.g. connect, purge_queue, create/delete topic) with params where allVhostsRequested(params) is true (all_vhosts set/enabled).","commonSituations":"A shared request builder that always sets all_vhosts=true for every call; copying a list-topics request and changing only the method name; misconfigured agent policies enabling all-vhost mode globally.","solutions":["Remove the all_vhosts flag from non-list method calls","Loop over vhosts yourself and issue one call per vhost with an explicit virtual_host","Use all_vhosts only with list operations"],"exampleFix":"// before\nagent.Call(\"mq_purge_queue\", map[string]any{\"topic\": \"q\", \"all_vhosts\": true})\n// after\nagent.Call(\"mq_purge_queue\", map[string]any{\"topic\": \"q\", \"virtual_host\": \"prod\"})","handlingStrategy":"validation","validationCode":"if allVhosts, ok := params[\"all_vhosts\"]; ok && allVhosts == true && !strings.Contains(method, \"list\") {\n\tdelete(params, \"all_vhosts\")\n}","typeGuard":"func isListMethod(method string) bool {\n\treturn strings.HasPrefix(method, \"mq_list\")\n}","tryCatchPattern":"result, err := agent.Call(method, params)\nif err != nil && strings.Contains(err.Error(), \"all_vhosts is only supported for list operations\") {\n\tdelete(params, \"all_vhosts\")\n\tresult, err = agent.Call(method, params) // retry scoped to one vhost\n}","preventionTips":["Only set all_vhosts in list-request builders","Don't reuse list request objects for mutating calls","Iterate vhosts manually for non-list operations"],"tags":["rabbitmq","validation","api-misuse"],"backgroundTag":"unsupported-operation","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"}