phacility/phabricator · error · Exception
Primary email addresses can not be reassigned.
Error message
Primary email addresses can not be reassigned.
What it means
Guard in PhabricatorUserEditor::createNewUser: when reusing an existing PhabricatorUserEmail with allow_reassign, the email turns out to be the primary address of its current owner; primary addresses can never be moved to another account.
Solutions
- Create the user with a brand-new, unclaimed email address instead.
- If the address legitimately belongs to the new user, change the primary on the old account first, then reassign the now-secondary address.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/applications/people/editor/PhabricatorUserEditor.php:37 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/e22cc08b4f3e4c4a.
Report an issue: GitHub.
Appendix: source
Thrown at src/applications/people/editor/PhabricatorUserEditor.php:37
/**
* @task edit
*/
public function createNewUser(
PhabricatorUser $user,
PhabricatorUserEmail $email,
$allow_reassign = false) {
if ($user->getID()) {
throw new Exception(pht('User has already been created!'));
}
$is_reassign = false;
if ($email->getID()) {
if ($allow_reassign) {
if ($email->getIsPrimary()) {
throw new Exception(
pht('Primary email addresses can not be reassigned.'));
}
$is_reassign = true;
} else {
throw new Exception(pht('Email has already been created!'));
}
}
if (!PhabricatorUser::validateUsername($user->getUsername())) {
$valid = PhabricatorUser::describeValidUsername();
throw new Exception(pht('Username is invalid! %s', $valid));
}
// Always set a new user's email address to primary.
$email->setIsPrimary(1);
// If the primary address is already verified, also set the verified flag
// on the user themselves.View on GitHub (pinned to 5720a38cfe)