{"record":{"id":"1c28751e4c27d1d1","repo":"phacility/phabricator","slug":"no-public-key-exists-with-id-s","errorCode":null,"errorMessage":"No public key exists with ID \"%s\".","messagePattern":"No public key exists with ID \"(.+?)\"\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/almanac/management/AlmanacManagementTrustKeyWorkflow.php","lineNumber":34,"sourceCode":"          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $console = PhutilConsole::getConsole();\n\n    $id = $args->getArg('id');\n    if (!$id) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify a public key to trust with --id.'));\n    }\n\n    $key = id(new PhabricatorAuthSSHKeyQuery())\n      ->setViewer($this->getViewer())\n      ->withIDs(array($id))\n      ->executeOne();\n    if (!$key) {\n      throw new PhutilArgumentUsageException(\n        pht('No public key exists with ID \"%s\".', $id));\n    }\n\n    if (!$key->getIsActive()) {\n      throw new PhutilArgumentUsageException(\n        pht('Public key \"%s\" is not an active key.', $id));\n    }\n\n    if ($key->getIsTrusted()) {\n      throw new PhutilArgumentUsageException(\n        pht('Public key with ID %s is already trusted.', $id));\n    }\n\n    if (!($key->getObject() instanceof AlmanacDevice)) {\n      throw new PhutilArgumentUsageException(\n        pht('You can only trust keys associated with Almanac devices.'));\n    }\n","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/management/AlmanacManagementTrustKeyWorkflow.php#L16-L52","documentation":"Usage exception from `bin/almanac trust-key`: PhabricatorAuthSSHKeyQuery->withIDs([$id])->executeOne() returned nothing, so no SSH public key row exists with that ID (as visible to the CLI viewer). IDs are the numeric primary keys of auth.sshkey rows, not key fingerprints, PHIDs, or device IDs.","triggerScenarios":"Trusting by device ID or object PHID instead of the SSH key row ID; the key was deleted before trust-key ran; transposed digits when copying the ID from the UI; running against a different instance than the one showing the key.","commonSituations":"Runbook confusion between device IDs and SSH key IDs; split-brain instances in dev/staging; keys removed during cleanup while automation still references them.","solutions":["Open the device in the web UI, go to Manage -> SSH Keys, and use the key's own ID (shown on the key object/URI).","Confirm the row exists: the key detail page (auth/sshkey/view/<id>/) should load for that same ID.","Check you are pointing at the right instance/environment before retrying."],"exampleFix":"# before\n$ bin/almanac trust-key --id 7   # 7 is the device ID, not the key ID\nUsage Exception: No public key exists with ID \"7\".\n\n# after\n$ bin/almanac trust-key --id 42  # 42 = ID from device -> Manage -> SSH Keys","handlingStrategy":"validation","validationCode":"// Confirm the key row exists before trusting\n$key = id(new PhabricatorAuthSSHKeyQuery())\n  ->setViewer($viewer)\n  ->withIDs(array($id))\n  ->executeOne();\nif (!$key) {\n  throw new RuntimeException(\"No SSH key with ID {$id}; check device -> Manage -> SSH Keys.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the SSH key row ID (auth/sshkey/view/<id>/), never the device ID or PHID.","Fetch the key ID via automation (device page / API) instead of transcribing digits.","Verify environment (dev/staging/prod) matches the instance where the key was created."],"tags":["phabricator","almanac","cli","entity-not-found","trust-key","ssh-key"],"backgroundTag":"entity-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}