t8y2/dbx · error

user name is required

Error message

user name is required

What it means

userName resolves the target RabbitMQ user from the "name" param, falling back to "user". If both are empty or whitespace, the operation (createUser, deleteUser, grantPermission, revokePermission) cannot proceed and this error is thrown, since every user-scoped operation needs a concrete user.

Source

Thrown at agents/drivers/rabbitmq/operations.go:982

func permissionVhost(params jsonObject) (string, error) {
	vhost := stringOrEmpty(params, "virtual_host")
	if strings.TrimSpace(vhost) == "" {
		return "", errors.New("virtual_host is required")
	}
	if vhost == "*" {
		return "", errors.New("all_vhosts is only supported for list operations")
	}
	return vhost, nil
}

func userName(params jsonObject) (string, error) {
	name := stringOrEmpty(params, "name")
	if strings.TrimSpace(name) == "" {
		name = stringOrEmpty(params, "user")
	}
	if strings.TrimSpace(name) == "" {
		return "", errors.New("user name is required")
	}
	return name, nil
}

func (s *server) listPolicies(params jsonObject) (any, error) {
	connection, err := s.requireConnectionConfig(params)
	if err != nil {
		return nil, err
	}
	allVhosts := allVhostsRequested(params) || stringOrEmpty(params, "virtual_host") == "*"
	path := "/api/policies/" + urlEncodeVhost(effectiveVhost(params, connection))
	if allVhosts {
		path = "/api/policies"
	}
	policies, err := managementGetAll(connection, path)
	if err != nil {
		return nil, err
	}

View on GitHub (pinned to c0390bff16)

Solutions

  1. Pass name:"<username>" to the operation
  2. Alternatively pass user:"<username>" (accepted fallback key)
  3. Check that the variable feeding the param is non-empty before dispatching

Example fix

// before
{ "op": "deleteUser", "username": "alice" }   // wrong key
// after
{ "op": "deleteUser", "name": "alice" }
Defensive patterns

Strategy: validation

Validate before calling

const user = (params.name ?? params.user ?? "").trim();
if (!user) throw new Error("user name is required");

Type guard

function hasUser(p) { return [p.name, p.user].some(v => typeof v === "string" && v.trim() !== ""); }

Try / catch

try { await agent.dispatch("deleteUser", params); } catch (e) { if (/user name is required/.test(e.message)) { /* fill name and retry */ } else throw e; }

Prevention

When it happens

Trigger: Calling createUser, deleteUser, grantPermission, or revokePermission with neither "name" nor "user" set, or both empty/whitespace.

Common situations: Deleting users with the wrong key (e.g. "username" or "userName"); empty variables from shell/env substitution; mixing up param naming between operations.

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


AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05). Data as JSON: /api/errors/1b4f8aa7f9a2f518. Report an issue: GitHub.