phacility/phabricator · warning · PhutilArgumentUsageException

Choose a build target to attach the log to with "--target".

Error message

Choose a build target to attach the log to with "--target".

What it means

Usage exception from 'bin/harbormaster write-log', a debugging tool that reads stdin and writes it into a new live build log. A HarbormasterBuildLog must belong to a HarbormasterBuildTarget, and --target is the only way to name one, so a missing --target aborts before any log is created.

Source

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

            'param' => 'id',
            'help' => pht('Build Target ID to attach the log to.'),
          ),
          array(
            'name' => 'rate',
            'param' => 'bytes',
            'help' => pht(
              'Limit the rate at which the log is written, to test '.
              'live log streaming.'),
          ),
        ));
  }

  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(

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Get a target ID from the build page (the target URI contains the numeric ID) and pass '--target <id>'
  2. Run a build first so a real target exists to attach the test log to

Example fix

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

Strategy: validation

Validate before calling

# shell wrapper before invoking write-log
if [ -z ${TARGET_ID:-} ]; then
  echo 'error: --target <id> is required' >&2
  exit 1
fi

Prevention

When it happens

Trigger: Running 'echo hi | bin/harbormaster write-log' with no --target flag.

Common situations: Testing live log streaming and forgetting the target; a script variable holding the target ID is empty.

Related errors


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