phacility/phabricator · error · PhutilArgumentUsageException

Failed to find an OAuth client with id %s.

Error message

Failed to find an OAuth client with id %s.

What it means

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.

Source

Thrown at src/applications/auth/management/PhabricatorAuthManagementTrustOAuthClientWorkflow.php:40

        ));
  }

  public function execute(PhutilArgumentParser $args) {
    $id = $args->getArg('id');

    if (!$id) {
      throw new PhutilArgumentUsageException(
        pht(
          'Specify an OAuth client id with "--id".'));
    }

    $client = id(new PhabricatorOAuthServerClientQuery())
      ->setViewer($this->getViewer())
      ->withIDs(array($id))
      ->executeOne();

    if (!$client) {
      throw new PhutilArgumentUsageException(
        pht(
          'Failed to find an OAuth client with id %s.', $id));
    }

    if ($client->getIsTrusted()) {
      throw new PhutilArgumentUsageException(
        pht(
          'OAuth client "%s" is already trusted.',
          $client->getName()));
    }

    $client->setIsTrusted(1);
    $client->save();

    $console = PhutilConsole::getConsole();
    $console->writeOut(
      "%s\n",
      pht(

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. 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.
  2. 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.
  3. 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>`.
  4. If the client genuinely no longer exists, recreate it in the OAuth Server UI before trusting it.

Example fix

// before
$ bin/auth trust-oauth-client --id PHID-OASC-xyz
Failed to find an OAuth client with id PHID-OASC-xyz.

// after
$ bin/auth trust-oauth-client --id 7
Done.
Defensive patterns

Strategy: validation

Validate before calling

// Before invoking the workflow, confirm the client exists:
$client = id(new PhabricatorOAuthServerClientQuery())
  ->setViewer(PhabricatorUser::getOmnipotentUser())
  ->withIDs(array($client_id))
  ->executeOne();
if (!$client) {
  // surface your own error listing valid client IDs instead of throwing
}

Try / catch

try {
  $err = new PhutilArgumentUsageException(pht('...'));
} catch (PhutilArgumentUsageException $ex) {
  // CLI usage failures: print $ex->getMessage() to stderr and exit non-zero
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/4c0ecd32b322a848. Report an issue: GitHub.