t8y2/dbx · error

all_vhosts is only supported for list operations

Error message

all_vhosts is only supported for list operations

What it means

permissionVhost rejects virtual_host="*" for mutating operations. Wildcard/all-vhosts semantics are only implemented for list operations; grant/revoke/setPolicy/deletePolicy must target exactly one vhost, so the library refuses "*" to avoid ambiguous bulk mutations.

Source

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

	}
	return okResult(), nil
}

func permissionPattern(params jsonObject, key string) string {
	pattern := stringOrEmpty(params, key)
	if strings.TrimSpace(pattern) == "" {
		return defaultPermissionPattern
	}
	return pattern
}

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 {

View on GitHub (pinned to c0390bff16)

Solutions

  1. Replace "*" with a concrete vhost name
  2. If bulk action is intended, list vhosts first and loop the operation per vhost
  3. Guard call sites to only pass "*" to list operations

Example fix

// before
await agent.dispatch("setPolicy", { name: "p", pattern: ".*", definition: {...}, virtual_host: "*" })
// after
for (const v of vhosts) {
  await agent.dispatch("setPolicy", { name: "p", pattern: ".*", definition: {...}, virtual_host: v })
}
Defensive patterns

Strategy: validation

Validate before calling

if (params.virtual_host === "*") throw new Error("list operations only; pass a concrete vhost");

Type guard

function isConcreteVhost(p) { return typeof p.virtual_host === "string" && p.virtual_host.trim() !== "" && p.virtual_host !== "*"; }

Try / catch

try { await agent.dispatch(op, params); } catch (e) { if (/all_vhosts is only supported/.test(e.message)) { /* expand wildcard into per-vhost calls */ } else throw e; }

Prevention

When it happens

Trigger: Passing virtual_host:"*" to grantPermission, revokePermission, setPolicy, or deletePolicy (a value valid for list operations only).

Common situations: Reusing a parameter template from listPermissions/listPolicies; assuming wildcard support like other tools' "all hosts" flags.

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/5d8d27a7ae1e5bf6. Report an issue: GitHub.