phacility/phabricator · error · Exception

User does not own email!

Error message

User does not own email!

What it means

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.

Solutions

  1. Add the address to the user first (addEmail plus verification), then change the primary.
  2. Verify the correct user/email pair is being passed to the editor.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/applications/people/editor/PhabricatorUserEditor.php:287 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/86204163d466bdee. Report an issue: GitHub.

Appendix: source

Thrown at src/applications/people/editor/PhabricatorUserEditor.php:287

    PhabricatorUser $user,
    PhabricatorUserEmail $email) {
    $actor = $this->requireActor();

    if (!$user->getID()) {
      throw new Exception(pht('User has not been created yet!'));
    }
    if (!$email->getID()) {
      throw new Exception(pht('Email has not been created yet!'));
    }

    $user->openTransaction();
      $user->beginWriteLocking();

        $user->reload();
        $email->reload();

        if ($email->getUserPHID() != $user->getPHID()) {
          throw new Exception(pht('User does not own email!'));
        }

        if ($email->getIsPrimary()) {
          throw new Exception(pht('Email is already primary!'));
        }

        if (!$email->getIsVerified()) {
          throw new Exception(pht('Email is not verified!'));
        }

        $old_primary = $user->loadPrimaryEmail();
        if ($old_primary) {
          $old_primary->setIsPrimary(0);
          $old_primary->save();
        }

        $email->setIsPrimary(1);
        $email->save();

View on GitHub (pinned to 5720a38cfe)