phacility/phabricator · warning · PhutilArgumentUsageException

Unable to load build target "%s".

Error message

Unable to load build target "%s".

What it means

Thrown by 'bin/harbormaster write-log' when --target is supplied but HarbormasterBuildTargetQuery loads no HarbormasterBuildTarget with that ID. The query runs as the CLI viewer (typically an admin), so a miss almost always means no target row with that ID exists in this instance.

Source

Thrown at src/applications/harbormaster/management/HarbormasterManagementWriteLogWorkflow.php:45

          ),
        ));
  }

  public function execute(PhutilArgumentParser $args) {
    $viewer = $this->getViewer();

    $target_id = $args->getArg('target');
    if (!$target_id) {
      throw new PhutilArgumentUsageException(
        pht('Choose a build target to attach the log to with "--target".'));
    }

    $target = id(new HarbormasterBuildTargetQuery())
      ->setViewer($viewer)
      ->withIDs(array($target_id))
      ->executeOne();
    if (!$target) {
      throw new PhutilArgumentUsageException(
        pht(
          'Unable to load build target "%s".',
          $target_id));
    }

    $log = HarbormasterBuildLog::initializeNewBuildLog($target);
    $log->openBuildLog();

    echo tsprintf(
      "%s\n\n        __%s__\n\n",
      pht('Opened a new build log:'),
      PhabricatorEnv::getURI($log->getURI()));

    echo tsprintf(
      "%s\n",
      pht('Reading log content from stdin...'));

    $content = file_get_contents('php://stdin');

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Confirm the ID from the build target URI (it contains /target/<id>/)
  2. List valid targets with harbormaster.target.search for the owning build
  3. Re-run the build to generate fresh targets if the old ones are gone

Example fix

# before
$ echo hi | bin/harbormaster write-log --target 99999
# after
$ echo hi | bin/harbormaster write-log --target 33
Defensive patterns

Strategy: validation

Validate before calling

$target = id(new HarbormasterBuildTargetQuery())
  ->setViewer($viewer)
  ->withIDs(array($target_id))
  ->executeOne();
if (!$target) {
  // no such target; get a fresh ID via harbormaster.target.search
}

Prevention

When it happens

Trigger: Running 'write-log --target 99999' where target 99999 does not exist; an ID copied from another environment; the target was removed when its build was cleaned up.

Common situations: Reusing stale target IDs after builds were re-run or garbage-collected; transcription errors when reading the ID from the UI.

Related errors


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