{"record":{"id":"59119f458296be8f","repo":"phacility/phabricator","slug":"oauth-client-s-is-already-trusted","errorCode":null,"errorMessage":"OAuth client \"%s\" is already trusted.","messagePattern":"OAuth client \"(.+?)\" is already trusted\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/auth/management/PhabricatorAuthManagementTrustOAuthClientWorkflow.php","lineNumber":46,"sourceCode":"    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(\n        'OAuth client \"%s\" is now trusted.',\n        $client->getName()));\n  }\n\n}\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/auth/management/PhabricatorAuthManagementTrustOAuthClientWorkflow.php#L28-L64","documentation":"Thrown by `bin/auth trust-oauth-client` when the requested OAuth client already has its isTrusted flag set. The workflow explicitly refuses to be a no-op: after loading the client it checks getIsTrusted() and aborts with this PhutilArgumentUsageException before calling setIsTrusted(1) and save(). The state of the database is unchanged.","triggerScenarios":"Running `bin/auth trust-oauth-client --id N` a second time for a client that was already trusted, or against a client that was marked trusted through the web UI previously.","commonSituations":"An automation script re-runs the trust command on every deploy; two admins trust the same client concurrently; the admin forgot the command had already succeeded earlier.","solutions":["Check the current state first: if the command says the client is already trusted, no action is needed — the desired state is already in effect.","Make idempotent scripts check state before acting (query PhabricatorOAuthServerClient or run `bin/auth trust-oauth-client` and treat this exception as success).","If you expected the client to be untrusted, confirm you used the right `--id` (a different client with the same name may be the one you meant).","To deliberately revert to untrusted, use `bin/auth untrust-oauth-client --id N` instead."],"exampleFix":"// before\n$ bin/auth trust-oauth-client --id 7   # already run before\nOAuth client \"wiki-frontend\" is already trusted.\n\n// after — idempotent wrapper\n$ bin/auth trust-oauth-client --id 7 2>/dev/null \\\n    || echo \"client already trusted or not found; nothing to do\"","handlingStrategy":"validation","validationCode":"if ($client->getIsTrusted()) {\n  // already in the desired state: skip the trust command entirely\n} else {\n  // safe to run: bin/auth trust-oauth-client --id <id>\n}","typeGuard":null,"tryCatchPattern":"try {\n  // run trust-oauth-client\n} catch (PhutilArgumentUsageException $ex) {\n  if (strpos($ex->getMessage(), 'already trusted') !== false) {\n    // treat as success — desired state already reached\n  }\n}","preventionTips":["Make admin scripts idempotent: check isTrusted before running the command.","Treat 'already trusted'/'already untrusted' messages as no-ops, not failures, in runbooks.","Document the current trust state next to each client ID in your ops notes."],"tags":["phabricator","cli","oauth","idempotency","invalid-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}