t8y2/dbx · error
namespace is required
Error message
namespace is required
What it means
namespaceName extracts the 'namespace' parameter (which maps to a RabbitMQ virtual host) for create/delete operations and rejects it when it is missing or only whitespace. The driver requires an explicit target vhost; it will not guess one. Callers (createNamespace, deleteNamespace) always funnel through this guard.
Source
Thrown at agents/drivers/rabbitmq/operations.go:361
return nil, err
}
connection, err := s.requireConnectionConfig(params)
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) {View on GitHub (pinned to c0390bff16)
Solutions
- Pass params["namespace"] with the target virtual host name, e.g. {"namespace": "my-vhost"}.
- Trim and validate the namespace value at your call site before invoking the driver.
- If the namespace comes from user input or config, fail fast with a clear message when it is empty.
Example fix
// before
agent.Call("createNamespace", map[string]any{})
// after
agent.Call("createNamespace", map[string]any{"namespace": "my-vhost"}) Defensive patterns
Strategy: validation
Validate before calling
func requireNamespace(params map[string]any) error {
ns, _ := params["namespace"].(string)
if strings.TrimSpace(ns) == "" {
return errors.New("caller validation: namespace must be a non-empty vhost name")
}
return nil
} Type guard
func hasNamespace(params map[string]any) bool {
ns, ok := params["namespace"].(string)
return ok && strings.TrimSpace(ns) != ""
} Try / catch
result, err := agent.Call("createNamespace", params)
if err != nil {
if err.Error() == "namespace is required" {
return fmt.Errorf("createNamespace requires params.namespace (target virtual host)")
}
return err
} Prevention
- Always set params["namespace"] for createNamespace/deleteNamespace.
- Use a single params-builder helper so required keys can't be forgotten.
- Validate config-derived namespaces are non-empty at startup.
- Don't rename the key to 'vhost' or 'name' in your call sites.
When it happens
Trigger: Calling createNamespace or deleteNamespace without a 'namespace' key in params, or with namespace:"", " ", or null.
Common situations: Building the params map dynamically and forgetting the namespace key; copying an example that used a different param name (e.g. 'vhost' or 'name'); a config/UI layer passing an empty selection through.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- topic (queue name) is required
- namespace create/delete requires a specific virtual host (al
- The default virtual host '/' cannot be deleted
- name is required
- password is required
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/427fb87ad037e0e2.
Report an issue: GitHub.