phacility/phabricator · warning · PhutilArgumentUsageException

Use one of "--id" or "--active" to select builds, but not bo

Error message

Use one of "--id" or "--active" to select builds, but not both.

What it means

Usage exception from 'bin/harbormaster restart'. --id selects an explicit set of builds and --active selects all currently active builds; supplying both is ambiguous, so the workflow requires exactly one selection strategy and throws when both are present.

Source

Thrown at src/applications/harbormaster/management/HarbormasterManagementRestartWorkflow.php:37

            'help' => pht('Select one or more builds by ID.'),
          ),
          array(
            'name' => 'active',
            'help' => pht('Select all active builds.'),
          ),
        ));
  }

  public function execute(PhutilArgumentParser $args) {
    $viewer = $this->getViewer();
    $ids = $args->getArg('id');
    $active = $args->getArg('active');

    if (!$ids && !$active) {
      throw new PhutilArgumentUsageException(
        pht('Use "--id" or "--active" to select builds.'));
    } if ($ids && $active) {
      throw new PhutilArgumentUsageException(
        pht('Use one of "--id" or "--active" to select builds, but not both.'));
    }

    $query = id(new HarbormasterBuildQuery())
      ->setViewer($viewer);
    if ($ids) {
      $query->withIDs($ids);
    } else {
      $query->withBuildStatuses(
        HarbormasterBuildStatus::getActiveStatusConstants());
    }
    $builds = $query->execute();

    $count = count($builds);
    if (!$count) {
      $this->logSkip(
        pht('SKIP'),
        pht('No builds to restart.'));

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Keep only the --id flags for a targeted restart
  2. Keep only --active to restart all active builds
  3. Encode 'exactly one of --id/--active' logic in automation scripts

Example fix

# before
$ bin/harbormaster restart --id 15 --active
# after
$ bin/harbormaster restart --id 15
Defensive patterns

Strategy: validation

Validate before calling

# shell wrapper: exactly one of --id / --active
if [ -n ${BUILD_IDS:-} ] && [ ${RESTART_ACTIVE:-0} -eq 1 ]; then
  echo 'error: use --id or --active, not both' >&2
  exit 1
fi

Prevention

When it happens

Trigger: Running 'bin/harbormaster restart --id 15 --active'.

Common situations: Scripts that append --active 'for safety' to every invocation; combining flags from different documentation examples.

Related errors


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