t8y2/dbx · error
The default virtual host '/' cannot be deleted
Error message
The default virtual host '/' cannot be deleted
What it means
assertNamespaceDeletable protects the default RabbitMQ virtual host '/'. RabbitMQ ships with '/' and deleting it would break default connections and client configs, so the driver refuses up front with this error instead of sending a doomed DELETE to the management API.
Source
Thrown at agents/drivers/rabbitmq/operations.go:371
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, err
}
allVhosts := allVhostsRequested(params)
exchanges, err := managementGetAll(connection, managementListPath(params, connection, "exchanges"))
if err != nil {
return nil, err
}
result := make([]jsonObject, 0, len(exchanges))View on GitHub (pinned to c0390bff16)
Solutions
- Skip the '/' vhost in your deletion loop: if ns == "/" { continue }.
- Delete only explicitly-named application vhosts, never the default one.
- If '/' is truly unwanted, recreate the broker/node rather than deleting the default vhost.
Example fix
// before
for _, vhost := range vhosts {
agent.Call("deleteNamespace", map[string]any{"namespace": vhost["name"]})
}
// after
for _, vhost := range vhosts {
if vhost["name"] == "/" {
continue
}
agent.Call("deleteNamespace", map[string]any{"namespace": vhost["name"]})
} Defensive patterns
Strategy: validation
Validate before calling
func assertDeletableVhost(ns string) error {
if ns == "/" {
return errors.New("refusing to delete the default virtual host '/'")
}
return nil
} Type guard
func isCustomVhost(ns string) bool {
return ns != "" && ns != "/"
} Try / catch
_, err := agent.Call("deleteNamespace", map[string]any{"namespace": ns})
if err != nil {
if strings.Contains(err.Error(), "default virtual host") {
// skip or abort; '/' must remain
return nil
}
return err
} Prevention
- Filter out '/' before looping over listNamespaces results.
- Document '/' as off-limits in cleanup scripts.
- Restrict the management user's permissions so it cannot delete '/' as a second line of defense.
When it happens
Trigger: Calling deleteNamespace with namespace == "/".
Common situations: Iterating all vhosts from listNamespaces (which includes '/') and deleting each; a cleanup script targeting every vhost; users misreading '/' as 'all vhosts' or an empty root.
Related errors
- namespace is required
- namespace create/delete requires a specific virtual host (al
- 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/c0c83bd3897b9dd9.
Report an issue: GitHub.