t8y2/dbx · error
namespace create/delete requires a specific virtual host (al
Error message
namespace create/delete requires a specific virtual host (all-vhosts context)
What it means
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.
Source
Thrown at agents/drivers/rabbitmq/operations.go:364
if err != nil {
return nil, err
}
if err := assertNamespaceDeletable(namespace, stringOrDefault(connection, "virtual_host", "/")); err != nil {
return nil, err
}
if _, err := managementSend(connection, http.MethodDelete, "/api/vhosts/"+urlEncodeVhost(namespace), nil); err != nil {
return nil, err
}
return okResult(), nil
}
func namespaceName(params jsonObject) (string, error) {
name := stringOrEmpty(params, "namespace")
if strings.TrimSpace(name) == "" {
return "", errors.New("namespace is required")
}
if strings.TrimSpace(name) == "*" {
return "", errors.New("namespace create/delete requires a specific virtual host (all-vhosts context)")
}
return name, nil
}
func assertNamespaceDeletable(namespace, connectedVhost string) error {
if namespace == "/" {
return errors.New("The default virtual host '/' cannot be deleted")
}
if connectedVhost != "" && namespace == connectedVhost {
return fmt.Errorf("Cannot delete the virtual host '%s' while connected to it", namespace)
}
return nil
}
func (s *server) listExchanges(params jsonObject) (any, error) {
connection, err := s.requireConnectionConfig(params)
if err != nil {
return nil, errView on GitHub (pinned to c0390bff16)
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.
Example fix
// before
for _, ns := range []string{"*"} {
agent.Call("deleteNamespace", map[string]any{"namespace": ns})
}
// after
namespaces, _ := agent.Call("listNamespaces", map[string]any{})
for _, ns := range namespaces {
agent.Call("deleteNamespace", map[string]any{"namespace": ns["name"]})
} Defensive patterns
Strategy: validation
Validate before calling
if ns, _ := params["namespace"].(string); ns == "*" {
return errors.New("cannot create/delete all vhosts; pick a specific virtual host")
} Type guard
func isSpecificNamespace(params map[string]any) bool {
ns, ok := params["namespace"].(string)
return ok && strings.TrimSpace(ns) != "" && strings.TrimSpace(ns) != "*"
} Try / catch
_, err := agent.Call("deleteNamespace", params)
if err != nil {
if strings.Contains(err.Error(), "all-vhosts context") {
return fmt.Errorf("namespace '%v' is a wildcard; call listNamespaces and delete each vhost explicitly", params["namespace"])
}
return err
} Prevention
- 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.
When it happens
Trigger: Calling createNamespace or deleteNamespace with params["namespace"] == "*".
Common situations: 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.
Understand the failure class
Background: "must be positive", "Invalid value": how libraries reject invalid parameter values (ValueError, ArgumentError, INVALID_PARAMETER_VALUE) — this error's family across 28 libraries.
Related errors
- namespace is required
- The default virtual host '/' cannot be deleted
- topic (queue name) is required
- all_vhosts is only supported for list operations
- name is required
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/d89bf25af6c9c1d9.
Report an issue: GitHub.