phacility/phabricator · error · PhutilArgumentUsageException

No public key exists with ID "%s".

Error message

No public key exists with ID "%s".

What it means

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.

Source

Thrown at src/applications/almanac/management/AlmanacManagementTrustKeyWorkflow.php:34

          ),
        ));
  }

  public function execute(PhutilArgumentParser $args) {
    $console = PhutilConsole::getConsole();

    $id = $args->getArg('id');
    if (!$id) {
      throw new PhutilArgumentUsageException(
        pht('Specify a public key to trust with --id.'));
    }

    $key = id(new PhabricatorAuthSSHKeyQuery())
      ->setViewer($this->getViewer())
      ->withIDs(array($id))
      ->executeOne();
    if (!$key) {
      throw new PhutilArgumentUsageException(
        pht('No public key exists with ID "%s".', $id));
    }

    if (!$key->getIsActive()) {
      throw new PhutilArgumentUsageException(
        pht('Public key "%s" is not an active key.', $id));
    }

    if ($key->getIsTrusted()) {
      throw new PhutilArgumentUsageException(
        pht('Public key with ID %s is already trusted.', $id));
    }

    if (!($key->getObject() instanceof AlmanacDevice)) {
      throw new PhutilArgumentUsageException(
        pht('You can only trust keys associated with Almanac devices.'));
    }

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. 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).
  2. Confirm the row exists: the key detail page (auth/sshkey/view/<id>/) should load for that same ID.
  3. Check you are pointing at the right instance/environment before retrying.

Example fix

# before
$ bin/almanac trust-key --id 7   # 7 is the device ID, not the key ID
Usage Exception: No public key exists with ID "7".

# after
$ bin/almanac trust-key --id 42  # 42 = ID from device -> Manage -> SSH Keys
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the key row exists before trusting
$key = id(new PhabricatorAuthSSHKeyQuery())
  ->setViewer($viewer)
  ->withIDs(array($id))
  ->executeOne();
if (!$key) {
  throw new RuntimeException("No SSH key with ID {$id}; check device -> Manage -> SSH Keys.");
}

Prevention

When it happens

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

Common situations: Runbook confusion between device IDs and SSH key IDs; split-brain instances in dev/staging; keys removed during cleanup while automation still references them.

Related errors


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