{"record":{"id":"86204163d466bdee","repo":"phacility/phabricator","slug":"user-does-not-own-email","errorCode":null,"errorMessage":"User does not own email!","messagePattern":"User does not own email!","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/people/editor/PhabricatorUserEditor.php","lineNumber":287,"sourceCode":"    PhabricatorUser $user,\n    PhabricatorUserEmail $email) {\n    $actor = $this->requireActor();\n\n    if (!$user->getID()) {\n      throw new Exception(pht('User has not been created yet!'));\n    }\n    if (!$email->getID()) {\n      throw new Exception(pht('Email has not been created yet!'));\n    }\n\n    $user->openTransaction();\n      $user->beginWriteLocking();\n\n        $user->reload();\n        $email->reload();\n\n        if ($email->getUserPHID() != $user->getPHID()) {\n          throw new Exception(pht('User does not own email!'));\n        }\n\n        if ($email->getIsPrimary()) {\n          throw new Exception(pht('Email is already primary!'));\n        }\n\n        if (!$email->getIsVerified()) {\n          throw new Exception(pht('Email is not verified!'));\n        }\n\n        $old_primary = $user->loadPrimaryEmail();\n        if ($old_primary) {\n          $old_primary->setIsPrimary(0);\n          $old_primary->save();\n        }\n\n        $email->setIsPrimary(1);\n        $email->save();","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/people/editor/PhabricatorUserEditor.php#L269-L305","documentation":"Raised in PhabricatorUserEditor::changePrimaryEmail under a write lock: after reloading both records, the email's getUserPHID() does not match the user's PHID, so the editor refuses to make an email primary that the user does not own. The faulting input is the mismatched email/user pair.","triggerScenarios":"Thrown at src/applications/people/editor/PhabricatorUserEditor.php:287 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the address to the user first (addEmail plus verification), then change the primary.","Verify the correct user/email pair is being passed to the editor."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","contentChangedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}