{"record":{"id":"a1d3a62c9d3fa541","repo":"phacility/phabricator","slug":"this-alias-is-already-in-use","errorCode":null,"errorMessage":"This alias is already in use.","messagePattern":"This alias is already in use\\.","errorType":"validation","errorClass":"PhabricatorApplicationTransactionValidationException","httpStatus":null,"severity":"warning","filePath":"src/applications/phurl/editor/PhabricatorPhurlURLEditor.php","lineNumber":107,"sourceCode":"      PhabricatorEnv::getProductionURI('/U'.$object->getID()));\n\n\n    return $body;\n  }\n\n  protected function didCatchDuplicateKeyException(\n    PhabricatorLiskDAO $object,\n    array $xactions,\n    Exception $ex) {\n\n    $errors = array();\n    $errors[] = new PhabricatorApplicationTransactionValidationError(\n      PhabricatorPhurlURLAliasTransaction::TRANSACTIONTYPE,\n      pht('Duplicate'),\n      pht('This alias is already in use.'),\n      null);\n\n    throw new PhabricatorApplicationTransactionValidationException($errors);\n  }\n\n  protected function buildReplyHandler(PhabricatorLiskDAO $object) {\n    return id(new PhabricatorPhurlURLReplyHandler())\n      ->setMailReceiver($object);\n  }\n\n}\n","sourceCodeStart":89,"sourceCodeEnd":116,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/phurl/editor/PhabricatorPhurlURLEditor.php#L89-L116","documentation":"When applying Phurl URL transactions, PhabricatorPhurlURLEditor::didCatchDuplicateKeyException() traps the MySQL duplicate-key error on the unique alias column and rethrows it as PhabricatorApplicationTransactionValidationException with the human message 'This alias is already in use.'. It is a form-level validation error: the save is cleanly rejected with no partial write, and the error is attached to the alias transaction type.","triggerScenarios":"Creating a Phurl URL, or renaming one, to an alias that another URL already holds, hitting the unique key on the alias column during the transaction.","commonSituations":"Two users claiming the same short alias concurrently; double-submitted forms; aliases still held by soft-deleted URLs so the alias looks free in the list but is not.","solutions":["Pick a different alias and resubmit","If the alias appears unused, check for a soft-deleted URL still holding it and restore or destroy that row","Catch PhabricatorApplicationTransactionValidationException and render the error next to the alias field instead of crashing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-check alias availability before applying transactions.\n$conflict = id(new PhabricatorPhurlURLQuery())\n  ->setViewer(PhabricatorUser::getOmnipotentUser())\n  ->withAliases(array($alias))\n  ->executeOne();\nif ($conflict) {\n  // surface a field error now instead of failing the save\n}","typeGuard":null,"tryCatchPattern":"try {\n  id(new PhabricatorPhurlURLEditor())\n    ->setActor($viewer)\n    ->setContentSource($source)\n    ->applyTransactions($url, $xactions);\n} catch (PhabricatorApplicationTransactionValidationException $ex) {\n  foreach ($ex->getErrors() as $error) {\n    // render 'This alias is already in use.' next to the alias field\n  }\n}","preventionTips":["Check alias availability inline while the user types","Treat soft-deleted URLs as alias holders until destroyed","Catch the validation exception type in editors so users see field errors, not crashes"],"tags":["phabricator","phurl","alias","unique-constraint","validation"],"backgroundTag":"unique-constraint-violation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}