phacility/phabricator · error · Exception

Unable to load API token ("%s")!

Error message

Unable to load API token ("%s")!

What it means

The Buildkite step loads its API token from a Passphrase credential whose PHID is stored in the step's 'token' setting, queried with needSecrets(true) as the omnipotent user. If no credential loads for that PHID, the step throws before any HTTP call and the build target fails: the stored PHID is empty, wrong, or the credential was deleted.

Source

Thrown at src/applications/harbormaster/step/HarbormasterBuildkiteBuildStepImplementation.php:143

    if ($author_identity) {
      $data_structure += array(
        'author' => array(
          'name' => $author_identity->getIdentityDisplayName(),
          'email' => $author_identity->getIdentityEmailAddress(),
        ),
      );
    }

    $json_data = phutil_json_encode($data_structure);

    $credential_phid = $this->getSetting('token');
    $api_token = id(new PassphraseCredentialQuery())
      ->setViewer($viewer)
      ->withPHIDs(array($credential_phid))
      ->needSecrets(true)
      ->executeOne();
    if (!$api_token) {
      throw new Exception(
        pht(
          'Unable to load API token ("%s")!',
          $credential_phid));
    }

    $token = $api_token->getSecret()->openEnvelope();

    $future = id(new HTTPSFuture($uri, $json_data))
      ->setMethod('POST')
      ->addHeader('Content-Type', 'application/json')
      ->addHeader('Accept', 'application/json')
      ->addHeader('Authorization', "Bearer {$token}")
      ->setTimeout(60);

    $this->resolveFutures(
      $build,
      $build_target,
      array($future));

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Create (or locate) the Buildkite API token credential in Passphrase and copy its PHID (PHID-CDTL-...)
  2. Update the Buildkite build step's token setting to that PHID and save the plan
  3. After any credential rotation, smoke-test one build to confirm the plan still resolves the token

Example fix

# before: step token setting = PHID-CDTL-deletedcredential
# after: create the credential in Passphrase, then set the Buildkite
# step token setting to the new credential PHID (PHID-CDTL-...)
Defensive patterns

Strategy: validation

Validate before calling

$credential = id(new PassphraseCredentialQuery())
  ->setViewer(PhabricatorUser::getOmnipotentUser())
  ->withPHIDs(array($credential_phid))
  ->executeOne();
if (!$credential) {
  // fix the step token setting before running builds
}

Prevention

When it happens

Trigger: The step's token setting references a deleted Passphrase credential; the PHID was never set or has a typo; the plan was imported from another instance where that credential PHID does not exist.

Common situations: Credential rotation or cleanup without updating the build plan; exporting/importing build plans across instances; a wrong PHID pasted into the step configuration.

Related errors


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