{"record":{"id":"b5540cce1028b55e","repo":"phacility/phabricator","slug":"you-can-only-recover-the-username-for-one-account","errorCode":null,"errorMessage":"You can only recover the username for one account.","messagePattern":"You can only recover the username for one account\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/auth/management/PhabricatorAuthManagementRecoverWorkflow.php","lineNumber":34,"sourceCode":"            'name' => 'force-full-session',\n            'help' => pht(\n              'Recover directly into a full session without requiring MFA '.\n              'or other login checks.'),\n          ),\n          array(\n            'name' => 'username',\n            'wildcard' => true,\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $usernames = $args->getArg('username');\n    if (!$usernames) {\n      throw new PhutilArgumentUsageException(\n        pht('You must specify the username of the account to recover.'));\n    } else if (count($usernames) > 1) {\n      throw new PhutilArgumentUsageException(\n        pht('You can only recover the username for one account.'));\n    }\n\n    $username = head($usernames);\n\n    $user = id(new PhabricatorPeopleQuery())\n      ->setViewer($this->getViewer())\n      ->withUsernames(array($username))\n      ->executeOne();\n\n    if (!$user) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'No such user \"%s\" to recover.',\n          $username));\n    }\n\n    if (!$user->canEstablishWebSessions()) {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/auth/management/PhabricatorAuthManagementRecoverWorkflow.php#L16-L52","documentation":"The username argument is a wildcard, so PhutilArgumentParser accepts several values syntactically, but account recovery is strictly per-account: count($usernames) > 1 aborts with PhutilArgumentUsageException and no recovery link is generated for any of them.","triggerScenarios":"Running './bin/auth recover alice bob' (two or more usernames) in one invocation.","commonSituations":"Bulk-recovering several locked-out users at once; paste lists into the command line assuming batch behavior.","solutions":["Recover accounts one at a time: ./bin/auth recover alice, then ./bin/auth recover bob.","For several accounts, loop in the shell: for u in alice bob; do ./bin/auth recover \"$u\"; done"],"exampleFix":"// before\n./bin/auth recover alice bob\n// after\nfor u in alice bob; do ./bin/auth recover \"$u\"; done","handlingStrategy":"validation","validationCode":"# guard: exactly one account per invocation\n[ \"$#\" -eq 1 ] || { echo 'one username at a time' >&2; exit 2; }\n./bin/auth recover \"$1\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Recovery is per-account; loop over usernames instead of passing several.","Do not paste space-separated lists into a single command.","Check argument count in wrapper scripts."],"tags":["cli","usage","account-recovery","phabricator"],"backgroundTag":"too-many-arguments","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}