{"record":{"id":"d89bf25af6c9c1d9","repo":"t8y2/dbx","slug":"namespace-create-delete-requires-a-specific-virtua","errorCode":null,"errorMessage":"namespace create/delete requires a specific virtual host (all-vhosts context)","messagePattern":"namespace create/delete requires a specific virtual host \\(all-vhosts context\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rabbitmq/operations.go","lineNumber":364,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := assertNamespaceDeletable(namespace, stringOrDefault(connection, \"virtual_host\", \"/\")); err != nil {\n\t\treturn nil, err\n\t}\n\tif _, err := managementSend(connection, http.MethodDelete, \"/api/vhosts/\"+urlEncodeVhost(namespace), nil); err != nil {\n\t\treturn nil, err\n\t}\n\treturn okResult(), nil\n}\n\nfunc namespaceName(params jsonObject) (string, error) {\n\tname := stringOrEmpty(params, \"namespace\")\n\tif strings.TrimSpace(name) == \"\" {\n\t\treturn \"\", errors.New(\"namespace is required\")\n\t}\n\tif strings.TrimSpace(name) == \"*\" {\n\t\treturn \"\", errors.New(\"namespace create/delete requires a specific virtual host (all-vhosts context)\")\n\t}\n\treturn name, nil\n}\n\nfunc assertNamespaceDeletable(namespace, connectedVhost string) error {\n\tif namespace == \"/\" {\n\t\treturn errors.New(\"The default virtual host '/' cannot be deleted\")\n\t}\n\tif connectedVhost != \"\" && namespace == connectedVhost {\n\t\treturn fmt.Errorf(\"Cannot delete the virtual host '%s' while connected to it\", namespace)\n\t}\n\treturn nil\n}\n\nfunc (s *server) listExchanges(params jsonObject) (any, error) {\n\tconnection, err := s.requireConnectionConfig(params)\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rabbitmq/operations.go#L346-L382","documentation":"namespaceName treats '*' as the all-vhosts wildcard context (used for operations spanning every virtual host). Because create and delete target exactly one virtual host, the wildcard is rejected with this error. The driver forces you to name a specific vhost for mutating namespace operations.","triggerScenarios":"Calling createNamespace or deleteNamespace with params[\"namespace\"] == \"*\".","commonSituations":"Reusing a wildcard namespace value from list/watch operations (where '*' means all vhosts) in a create/delete call; a UI passing its 'all' selection into delete; template/config expansion emitting '*' as the vhost.","solutions":["Replace namespace:\"*\" with the concrete virtual host name you intend to create or delete.","Enumerate vhosts via listNamespaces and iterate, calling create/delete per specific vhost if you truly want all-vhosts behavior.","Guard your call site: if namespace == \"*\", either skip or resolve to an explicit vhost first."],"exampleFix":"// before\nfor _, ns := range []string{\"*\"} {\n    agent.Call(\"deleteNamespace\", map[string]any{\"namespace\": ns})\n}\n// after\nnamespaces, _ := agent.Call(\"listNamespaces\", map[string]any{})\nfor _, ns := range namespaces {\n    agent.Call(\"deleteNamespace\", map[string]any{\"namespace\": ns[\"name\"]})\n}","handlingStrategy":"validation","validationCode":"if ns, _ := params[\"namespace\"].(string); ns == \"*\" {\n    return errors.New(\"cannot create/delete all vhosts; pick a specific virtual host\")\n}","typeGuard":"func isSpecificNamespace(params map[string]any) bool {\n    ns, ok := params[\"namespace\"].(string)\n    return ok && strings.TrimSpace(ns) != \"\" && strings.TrimSpace(ns) != \"*\"\n}","tryCatchPattern":"_, err := agent.Call(\"deleteNamespace\", params)\nif err != nil {\n    if strings.Contains(err.Error(), \"all-vhosts context\") {\n        return fmt.Errorf(\"namespace '%v' is a wildcard; call listNamespaces and delete each vhost explicitly\", params[\"namespace\"])\n    }\n    return err\n}","preventionTips":["Reserve '*' for list/watch operations only.","Keep wildcard values out of mutating code paths by typing them separately in your app.","When iterating vhosts, pass the concrete name from each entry, never the selector."],"tags":["rabbitmq","validation","wildcard","vhost"],"backgroundTag":"invalid-parameter-value","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"}