phacility/phabricator · error · Exception
Email not owned by user!
Error message
Email not owned by user!
What it means
Ownership guard in removeEmail: after both records are reloaded under lock, the email's getUserPHID() does not match the target user's PHID, so the editor refuses to detach an email belonging to a different account.
Solutions
- Pass the PhabricatorUser that actually owns the email record.
- Reload both objects immediately before the call so stale PHIDs are not used.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/applications/people/editor/PhabricatorUserEditor.php:241 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/7b0e3a515b5c9a84.
Report an issue: GitHub.
Appendix: source
Thrown at src/applications/people/editor/PhabricatorUserEditor.php:241
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->getIsPrimary()) {
throw new Exception(pht("Can't remove primary email!"));
}
if ($email->getUserPHID() != $user->getPHID()) {
throw new Exception(pht('Email not owned by user!'));
}
$destruction_engine = id(new PhabricatorDestructionEngine())
->setWaitToFinalizeDestruction(true)
->destroyObject($email);
$log = PhabricatorUserLog::initializeNewLog(
$actor,
$user->getPHID(),
PhabricatorRemoveEmailUserLogType::LOGTYPE);
$log->setOldValue($email->getAddress());
$log->save();
$user->endWriteLocking();
$user->saveTransaction();
$this->revokePasswordResetLinks($user);
$destruction_engine->finalizeDestruction();View on GitHub (pinned to 5720a38cfe)