{"record":{"id":"1b4f8aa7f9a2f518","repo":"t8y2/dbx","slug":"user-name-is-required","errorCode":null,"errorMessage":"user name is required","messagePattern":"user name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agents/drivers/rabbitmq/operations.go","lineNumber":982,"sourceCode":"\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\nfunc (s *server) listPolicies(params jsonObject) (any, error) {\n\tconnection, err := s.requireConnectionConfig(params)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tallVhosts := allVhostsRequested(params) || stringOrEmpty(params, \"virtual_host\") == \"*\"\n\tpath := \"/api/policies/\" + urlEncodeVhost(effectiveVhost(params, connection))\n\tif allVhosts {\n\t\tpath = \"/api/policies\"\n\t}\n\tpolicies, err := managementGetAll(connection, path)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":964,"sourceCodeEnd":1000,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/rabbitmq/operations.go#L964-L1000","documentation":"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.","triggerScenarios":"Calling createUser, deleteUser, grantPermission, or revokePermission with neither \"name\" nor \"user\" set, or both empty/whitespace.","commonSituations":"Deleting users with the wrong key (e.g. \"username\" or \"userName\"); empty variables from shell/env substitution; mixing up param naming between operations.","solutions":["Pass name:\"<username>\" to the operation","Alternatively pass user:\"<username>\" (accepted fallback key)","Check that the variable feeding the param is non-empty before dispatching"],"exampleFix":"// before\n{ \"op\": \"deleteUser\", \"username\": \"alice\" }   // wrong key\n// after\n{ \"op\": \"deleteUser\", \"name\": \"alice\" }","handlingStrategy":"validation","validationCode":"const user = (params.name ?? params.user ?? \"\").trim();\nif (!user) throw new Error(\"user name is required\");","typeGuard":"function hasUser(p) { return [p.name, p.user].some(v => typeof v === \"string\" && v.trim() !== \"\"); }","tryCatchPattern":"try { await agent.dispatch(\"deleteUser\", params); } catch (e) { if (/user name is required/.test(e.message)) { /* fill name and retry */ } else throw e; }","preventionTips":["Use the \"name\" key for user-scoped operations","Log/echo params before dispatch to catch empty variables","Normalize param keys in your wrapper layer"],"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"}