{"record":{"id":"3e84696b218af072","repo":"phacility/phabricator","slug":"user-account-s-is-already-an-administrator-you","errorCode":null,"errorMessage":"User account \"%s\" is already an administrator. You can only empower accounts that are not yet administrators.","messagePattern":"User account \"(.+?)\" is already an administrator\\. You can only empower accounts that are not yet administrators\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/people/management/PhabricatorPeopleManagementEmpowerWorkflow.php","lineNumber":23,"sourceCode":"\n  protected function didConstruct() {\n    $arguments = array_merge(\n      $this->getUserSelectionArguments(),\n      array());\n\n    $this\n      ->setName('empower')\n      ->setExamples('**empower** --user __username__')\n      ->setSynopsis(pht('Turn a user account into an administrator account.'))\n      ->setArguments($arguments);\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $user = $this->selectUser($args);\n    $display_name = $user->getUsername();\n\n    if ($user->getIsAdmin()) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'User account \"%s\" is already an administrator. You can only '.\n          'empower accounts that are not yet administrators.',\n          $display_name));\n    }\n\n    $xactions = array();\n    $xactions[] = $user->getApplicationTransactionTemplate()\n      ->setTransactionType(PhabricatorUserEmpowerTransaction::TRANSACTIONTYPE)\n      ->setNewValue(true);\n\n    $this->applyTransactions($user, $xactions);\n\n    $this->logOkay(\n      pht('DONE'),\n      pht('Empowered user account \"%s\".', $display_name));\n\n    return 0;","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/management/PhabricatorPeopleManagementEmpowerWorkflow.php#L5-L41","documentation":"Thrown by `bin/people empower --user <username>` when the target account already has isAdmin set. The empower workflow only turns a regular user into an administrator; empowering an existing administrator is a no-op state transition, so the command aborts with a PhutilArgumentUsageException instead of applying an empty transaction.","triggerScenarios":"Running `./bin/people empower --user alice` on an account that is already an administrator; promotion scripts re-run against the same users; promoting a user who was elevated through the admin UI earlier.","commonSituations":"Repeat runs of provisioning automation; operators double-running the command to 'make sure';恢复 scripts after partial failures that already elevated the account.","solutions":["No fix needed - the account is already an administrator; verify the 'Administrator' badge on the People profile","In scripts, check isAdmin (Conduit user.query / PhabricatorPeopleQuery) before invoking empower","Treat the 'already an administrator' usage exception as a successful no-op in automation"],"exampleFix":"# before\n./bin/people empower --user alice\n# after (idempotent script guard)\n./bin/people empower --user \"$USERNAME\" 2>&1 | grep -q 'already an administrator' \\\n  && echo \"$USERNAME: already admin (ok)\"","handlingStrategy":"validation","validationCode":"$user = id(new PhabricatorPeopleQuery())\n  ->setViewer($viewer)\n  ->withUsernames(array($username))\n  ->executeOne();\nif (!$user || $user->getIsAdmin()) {\n  return; // already an administrator\n}","typeGuard":"function isAlreadyAdmin(PhabricatorUser $user) {\n  return (bool)$user->getIsAdmin();\n}","tryCatchPattern":null,"preventionTips":["Check isAdmin before empowering in provisioning scripts","Treat the 'already an administrator' message as a no-op success","Audit elevation changes via the user's transaction history instead of re-running the command"],"tags":["phabricator","cli","people","administrator","phutil","idempotency"],"backgroundTag":"invalid-state-transition","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}