{"record":{"id":"c84356ad2cfa4330","repo":"t8y2/dbx","slug":"virtual-host-is-required","errorCode":null,"errorMessage":"virtual_host is required","messagePattern":"virtual_host is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rabbitmq/operations.go","lineNumber":968,"sourceCode":"\tif _, err := managementSend(connection, http.MethodDelete,\n\t\t\"/api/permissions/\"+urlEncodeVhost(vhost)+\"/\"+urlEncodePathSegment(user), nil); err != nil {\n\t\treturn nil, err\n\t}\n\treturn okResult(), nil\n}\n\nfunc permissionPattern(params jsonObject, key string) string {\n\tpattern := stringOrEmpty(params, key)\n\tif strings.TrimSpace(pattern) == \"\" {\n\t\treturn defaultPermissionPattern\n\t}\n\treturn pattern\n}\n\nfunc permissionVhost(params jsonObject) (string, error) {\n\tvhost := stringOrEmpty(params, \"virtual_host\")\n\tif strings.TrimSpace(vhost) == \"\" {\n\t\treturn \"\", errors.New(\"virtual_host is required\")\n\t}\n\tif vhost == \"*\" {\n\t\treturn \"\", errors.New(\"all_vhosts is only supported for list operations\")\n\t}\n\treturn vhost, nil\n}\n\nfunc userName(params jsonObject) (string, error) {\n\tname := stringOrEmpty(params, \"name\")\n\tif strings.TrimSpace(name) == \"\" {\n\t\tname = stringOrEmpty(params, \"user\")\n\t}\n\tif strings.TrimSpace(name) == \"\" {\n\t\treturn \"\", errors.New(\"user name is required\")\n\t}\n\treturn name, nil\n}\n","sourceCodeStart":950,"sourceCodeEnd":986,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rabbitmq/operations.go#L950-L986","documentation":"permissionVhost validates the virtual_host parameter for RabbitMQ permission operations (grantPermission, revokePermission, setPolicy, deletePolicy). RabbitMQ permissions and policies are scoped to a specific virtual host, so a non-empty virtual_host must be supplied. This library throws it when the parameter is missing or only whitespace.","triggerScenarios":"Calling grantPermission, revokePermission, setPolicy, or deletePolicy without a virtual_host param, or with virtual_host set to \"\" or whitespace only.","commonSituations":"Scripts built for list operations that omit virtual_host; config objects where virtual_host defaults to empty; copying calls from listCommands (which accept \"*\") into mutating commands.","solutions":["Add a non-empty virtual_host parameter to the operation call","Verify the vhost name against `rabbitmqctl list_vhosts` or the listVirtualHosts operation","Do not use \"*\" for mutation operations; iterate over vhosts explicitly instead"],"exampleFix":"// before\n{ \"op\": \"grantPermission\", \"name\": \"alice\", \"pattern\": \".*\" }\n// after\n{ \"op\": \"grantPermission\", \"name\": \"alice\", \"pattern\": \".*\", \"virtual_host\": \"myapp-prod\" }","handlingStrategy":"validation","validationCode":"const vhost = params.virtual_host?.trim();\nif (!vhost) throw new Error(\"virtual_host is required\");\nif (vhost === \"*\") throw new Error(\"use a concrete vhost for mutating operations\");","typeGuard":"function hasVhost(p) { return typeof p.virtual_host === \"string\" && p.virtual_host.trim().length > 0; }","tryCatchPattern":"try { await agent.dispatch(\"grantPermission\", params); } catch (e) { if (/virtual_host is required/.test(e.message)) { /* prompt for vhost and retry */ } else throw e; }","preventionTips":["Always include virtual_host in permission/policy mutation params","Never pass \"*\" to mutating operations","Validate params centrally before dispatch"],"tags":["rabbitmq","parameter-validation","missing-parameter"],"backgroundTag":"missing-required-parameter","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}