{"record":{"id":"787d75636134b4ec","repo":"phacility/phabricator","slug":"user-account-s-is-already-approved-you-can-onl","errorCode":null,"errorMessage":"User account \"%s\" is already approved. You can only approve accounts that are not yet approved.","messagePattern":"User account \"(.+?)\" is already approved\\. You can only approve accounts that are not yet approved\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/people/management/PhabricatorPeopleManagementApproveWorkflow.php","lineNumber":24,"sourceCode":"\n  protected function didConstruct() {\n    $arguments = array_merge(\n      $this->getUserSelectionArguments(),\n      array());\n\n    $this\n      ->setName('approve')\n      ->setExamples('**approve** --user __username__')\n      ->setSynopsis(pht('Approves a user.'))\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->getIsApproved()) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'User account \"%s\" is already approved. You can only '.\n          'approve accounts that are not yet approved.',\n          $display_name));\n    }\n\n    $xactions = array();\n    $xactions[] = $user->getApplicationTransactionTemplate()\n      ->setTransactionType(PhabricatorUserApproveTransaction::TRANSACTIONTYPE)\n      ->setNewValue(true);\n\n    $this->applyTransactions($user, $xactions);\n\n    $this->logOkay(\n      pht('DONE'),\n      pht('Approved user account \"%s\".', $display_name));\n\n    return 0;","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/management/PhabricatorPeopleManagementApproveWorkflow.php#L6-L42","documentation":"Thrown by the Phabricator people-management CLI (`bin/people approve --user <username>`) when the target account's isApproved flag is already true. The approve workflow refuses to apply a no-op approval transaction, so management commands always represent a real state change. The account is already in the requested state, so the command exits with a PhutilArgumentUsageException instead of writing transactions.","triggerScenarios":"Running `./bin/people approve --user alice` when alice is already approved; re-running a bulk onboarding/approval script over already-approved users; approving an account that was already approved through the admin UI or a previous CLI run.","commonSituations":"Bulk-approval automation re-executed without state checks; operators 'verifying' approval took effect by re-running the command; installs where accounts get auto-approved (e.g. by email verification) and an admin tries to approve manually.","solutions":["No fix required - the account is already approved; confirm on the People > username profile page","If scripting bulk approvals, query the current state first (PhabricatorPeopleQuery or Conduit user.query) and skip users where isApproved is true","Treat this specific usage exception as success (idempotent no-op) in automation by checking state beforehand or matching the message"],"exampleFix":"# before\n./bin/people approve --user alice\n# after (idempotent script guard)\n./bin/people approve --user \"$USERNAME\" 2>&1 | grep -q 'already approved' \\\n  && echo \"$USERNAME: already approved (ok)\"","handlingStrategy":"validation","validationCode":"// Resolve the user and check approval state before invoking the workflow\n$user = id(new PhabricatorPeopleQuery())\n  ->setViewer($viewer)\n  ->withUsernames(array($username))\n  ->executeOne();\nif (!$user || $user->getIsApproved()) {\n  return; // nothing to approve\n}","typeGuard":"function isAlreadyApproved(PhabricatorUser $user) {\n  return (bool)$user->getIsApproved();\n}","tryCatchPattern":null,"preventionTips":["Make approval scripts idempotent: check isApproved before calling `bin/people approve`","Treat the 'already approved' usage exception as success in automation","Confirm account state on the People profile before re-running management commands"],"tags":["phabricator","cli","people","approval","phutil","idempotency"],"backgroundTag":"invalid-state-transition","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}