phacility/phabricator · error · Exception

Unknown CircleCI build type "%s". Expected "%s" or "%s".

Error message

Unknown CircleCI build type "%s". Expected "%s" or "%s".

What it means

The buildable's getCircleCIBuildIdentifierType() must return exactly 'tag' (for commits) or 'revision' (for code review objects); the switch in execute() throws for any other value. This is a hard contract of HarbormasterCircleCIBuildableInterface, and the returned string is used to pick the JSON key ('tag' or 'revision') sent to the CircleCI API.

Source

Thrown at src/applications/harbormaster/step/HarbormasterCircleCIBuildStepImplementation.php:172

    $token = $api_token->getSecret()->openEnvelope();
    $parts = array(
      'https://circleci.com/api/v1/project',
      phutil_escape_uri($github_namespace),
      phutil_escape_uri($github_name)."?circle-token={$token}",
    );

    $uri = implode('/', $parts);

    $data_structure = array();
    switch ($build_type) {
      case 'tag':
        $data_structure['tag'] = $build_identifier;
        break;
      case 'revision':
        $data_structure['revision'] = $build_identifier;
        break;
      default:
        throw new Exception(
          pht(
            'Unknown CircleCI build type "%s". Expected "%s" or "%s".',
            $build_type,
            'tag',
            'revision'));
    }

    $data_structure['build_parameters'] = array(
      'HARBORMASTER_BUILD_TARGET_PHID' => $build_target->getPHID(),
    );

    $json_data = phutil_json_encode($data_structure);

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

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Make getCircleCIBuildIdentifierType() return 'revision' for review objects or 'tag' for commit objects, exactly lowercase.
  2. Audit every implementer of HarbormasterCircleCIBuildableInterface if you extend Phabricator, since the step accepts only these two values.
  3. If you need a new identifier type, the step implementation itself must be extended to handle it before any implementer returns it.

Example fix

// before
public function getCircleCIBuildIdentifierType() {
  return 'branch';
}

// after
public function getCircleCIBuildIdentifierType() {
  return 'revision';
}
Defensive patterns

Strategy: type-guard

Validate before calling

// In tests or step preconditions:
$type = $object->getCircleCIBuildIdentifierType();
if (!in_array($type, array('tag', 'revision'), true)) {
  // do not run the CircleCI step for this buildable
}

Type guard

function isValidCircleCIBuildIdentifierType($type) {
  return in_array($type, array('tag', 'revision'), true);
}

Prevention

When it happens

Trigger: A class implementing HarbormasterCircleCIBuildableInterface returns something else from getCircleCIBuildIdentifierType(): a typo, a case mismatch ('Revision'), or a newly invented type like 'branch'. Core Phabricator implementations only return 'tag' (PhabricatorRepositoryCommit) and 'revision' (DifferentialRevision).

Common situations: Third-party or custom applications add their own buildable objects and copy the interface incorrectly; refactoring renames the constants; the value is computed and an empty string is returned on an unhandled branch.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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