{"record":{"id":"4c0ecd32b322a848","repo":"phacility/phabricator","slug":"failed-to-find-an-oauth-client-with-id-s","errorCode":null,"errorMessage":"Failed to find an OAuth client with id %s.","messagePattern":"Failed to find an OAuth client with id (.+?)\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/auth/management/PhabricatorAuthManagementTrustOAuthClientWorkflow.php","lineNumber":40,"sourceCode":"        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $id = $args->getArg('id');\n\n    if (!$id) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify an OAuth client id with \"--id\".'));\n    }\n\n    $client = id(new PhabricatorOAuthServerClientQuery())\n      ->setViewer($this->getViewer())\n      ->withIDs(array($id))\n      ->executeOne();\n\n    if (!$client) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Failed to find an OAuth client with id %s.', $id));\n    }\n\n    if ($client->getIsTrusted()) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'OAuth client \"%s\" is already trusted.',\n          $client->getName()));\n    }\n\n    $client->setIsTrusted(1);\n    $client->save();\n\n    $console = PhutilConsole::getConsole();\n    $console->writeOut(\n      \"%s\\n\",\n      pht(","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/auth/management/PhabricatorAuthManagementTrustOAuthClientWorkflow.php#L22-L58","documentation":"Thrown by the `bin/auth trust-oauth-client` management workflow when the `--id` value does not match any row in the OAuth server client table (PhabricatorOAuthServerClient) visible to the administrative viewer. The workflow loads the client with PhabricatorOAuthServerClientQuery->withIDs() and executeOne(); a falsy result aborts with this PhutilArgumentUsageException before any state change. It is purely a lookup failure, not a permission or storage error.","triggerScenarios":"Running `bin/auth trust-oauth-client --id N` where N is not the numeric ID of an existing OAuth client: the ID was mistyped, copied from a PHID instead of the numeric ID, the client was deleted, or the CLI is pointed at a different database/environment than the one where the client was created.","commonSituations":"Admin copies the client PHID (PHID-OASC-...) or the client name instead of the numeric ID from the OAuth Server console; the client record was removed but the ID is still in the admin's notes; staging vs production database confusion; the client list was pruned during a cleanup.","solutions":["Confirm the numeric ID of the OAuth client in the web UI under Applications -> OAuth Server (the ID column in the client list) or by querying the database directly.","If you only have the client name, look up the row: `SELECT id, name FROM oauth_server_oauthserverclient;` and re-run the command with the correct numeric id.","Verify you are running the command against the correct environment's database (phabricator config and env selection) and re-run `bin/auth trust-oauth-client --id <correct-id>`.","If the client genuinely no longer exists, recreate it in the OAuth Server UI before trusting it."],"exampleFix":"// before\n$ bin/auth trust-oauth-client --id PHID-OASC-xyz\nFailed to find an OAuth client with id PHID-OASC-xyz.\n\n// after\n$ bin/auth trust-oauth-client --id 7\nDone.","handlingStrategy":"validation","validationCode":"// Before invoking the workflow, confirm the client exists:\n$client = id(new PhabricatorOAuthServerClientQuery())\n  ->setViewer(PhabricatorUser::getOmnipotentUser())\n  ->withIDs(array($client_id))\n  ->executeOne();\nif (!$client) {\n  // surface your own error listing valid client IDs instead of throwing\n}","typeGuard":null,"tryCatchPattern":"try {\n  $err = new PhutilArgumentUsageException(pht('...'));\n} catch (PhutilArgumentUsageException $ex) {\n  // CLI usage failures: print $ex->getMessage() to stderr and exit non-zero\n}","preventionTips":["Always resolve the numeric client ID from the OAuth Server list (or a query) instead of hand-copying identifiers.","Never pass PHIDs where the workflow expects a numeric ID.","In automation, verify the ID exists in the target database before running trust/untrust commands."],"tags":["phabricator","cli","oauth","usage-exception","record-not-found"],"backgroundTag":"entity-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}