phacility/phabricator · error · PhutilArgumentUsageException

No public key exists with ID "%s".

Error message

No public key exists with ID "%s".

What it means

The untrust-key workflow loaded no SSH public key for the given --id. PhabricatorAuthSSHKeyQuery withIDs(array($id)) executed and executeOne() returned null, meaning no key row has that ID.

Source

Thrown at src/applications/almanac/management/AlmanacManagementUntrustKeyWorkflow.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 revoke trust for 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->getIsTrusted()) {
      throw new PhutilArgumentUsageException(
        pht('Public key with ID %s is not trusted.', $id));
    }

    $key->setIsTrusted(0);
    $key->save();

    PhabricatorAuthSSHKeyQuery::deleteSSHKeyCache();

    $console->writeOut(
      "**<bg:green> %s </bg>** %s\n",
      pht('TRUST REVOKED'),
      pht('Trust has been revoked for public key %s.', $id));
  }

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Locate the correct numeric key ID on the device's detail page in Almanac (or SSH key search) and retry with it.
  2. If the key was deleted, there is nothing to untrust; confirm the trust state of the remaining device keys instead.
  3. Double-check you passed the key's numeric ID, not a PHID or user ID.
Defensive patterns

Strategy: validation

Validate before calling

$key = id(new PhabricatorAuthSSHKeyQuery())
  ->setViewer($viewer)
  ->withIDs(array($id))
  ->executeOne();
if (!$key) {
  // Fail with your own actionable message instead of the workflow's.
  throw new Exception("SSH key {$id} not found; list keys on the device page.");
}

Try / catch

try {
  // run untrust-key
} catch (PhutilArgumentUsageException $ex) {
  if (preg_match('/No public key exists with ID/', $ex->getMessage())) {
    // Wrong or stale ID: re-resolve the device's key ID and retry once.
  } else {
    throw $ex;
  }
}

Prevention

When it happens

Trigger: Running ./bin/almanac untrust-key --id N where N does not match any row in the auth SSH key table (typo, stale ID from a deleted key, ID confused with a PHID or another object's ID).

Common situations: Using an ID copied from a different install or a key deleted after the admin note was written; mixing up the key ID shown in URLs of other objects.

Related errors


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