{"record":{"id":"2503dae313050242","repo":"phacility/phabricator","slug":"certificate-token-points-to-an-invalid-user","errorCode":null,"errorMessage":"Certificate token points to an invalid user!","messagePattern":"Certificate token points to an invalid user!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php","lineNumber":72,"sourceCode":"      'token = %s',\n      trim($token));\n\n    if (!$info || $info->getDateCreated() < time() - (60 * 15)) {\n      $this->logFailure($request, $info);\n      throw new ConduitException('ERR-BAD-TOKEN');\n    } else {\n      $log = PhabricatorUserLog::initializeNewLog(\n          $request->getUser(),\n          $info->getUserPHID(),\n          PhabricatorConduitCertificateUserLogType::LOGTYPE)\n        ->save();\n    }\n\n    $user = id(new PhabricatorUser())->loadOneWhere(\n      'phid = %s',\n      $info->getUserPHID());\n    if (!$user) {\n      throw new Exception(pht('Certificate token points to an invalid user!'));\n    }\n\n    return array(\n      'username'    => $user->getUserName(),\n      'certificate' => $user->getConduitCertificate(),\n    );\n  }\n\n  private function logFailure(\n    ConduitAPIRequest $request,\n    PhabricatorConduitCertificateToken $info = null) {\n\n    $log = PhabricatorUserLog::initializeNewLog(\n        $request->getUser(),\n        $info ? $info->getUserPHID() : '-',\n        PhabricatorConduitCertificateFailureUserLogType::LOGTYPE)\n      ->save();\n  }","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/conduit/method/ConduitGetCertificateConduitAPIMethod.php#L54-L90","documentation":"After a certificate token row validates, conduit.getcertificate loads the user by the row's userPHID. If no PhabricatorUser matches that PHID, the token references a user that no longer exists and a plain Exception is thrown ('Certificate token points to an invalid user!'). This is a data-integrity break between the token table and the user table, not a client-input error.","triggerScenarios":"The user account was deleted (or the row lost in a partial DB restore/import) between token creation and redemption; PHID references desynchronized after manual database surgery.","commonSituations":"Rare operational edge: token minted, then the owning account (often a bot) removed; dev/staging databases copied inconsistently from production.","solutions":["Mint a fresh token as an existing user and redeem it promptly; the new row will reference a live PHID.","If it recurs, inspect phabricator_conduit_certificate_token for rows whose userPHID has no match in the user table and purge stale rows.","Audit why the user record disappeared (deletion, restore, import) before recreating the account."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  $result = $call->execute();\n} catch (Exception $ex) {\n  if (preg_match('/invalid user/', $ex->getMessage())) {\n    // Server-side integrity issue: mint a new token for an existing user and retry.\n  }\n}","preventionTips":["Delete or disable bot accounts deliberately and purge their outstanding certificate tokens.","After partial DB restores or imports, check token tables for PHIDs with no matching user row."],"tags":["conduit","auth","data-integrity","phabricator","php"],"backgroundTag":"orphaned-record-reference","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}