phacility/phabricator · warning · PhutilArgumentUsageException

Choose an archival mode with --mode.

Error message

Choose an archival mode with --mode.

What it means

Usage error from the `bin harbormaster archive-logs` management workflow: the --mode argument is required and was not supplied. The command iterates every HarbormasterBuildLog and rewrites its storage, so an explicit mode (plain or compress) is mandatory.

Source

Thrown at src/applications/harbormaster/management/HarbormasterManagementArchiveLogsWorkflow.php:34

            'help' => pht(
              'Use "plain" to remove encoding, or "compress" to compress '.
              'logs.'),
          ),
          array(
            'name' => 'details',
            'help' => pht(
              'Show more details about operations as they are performed. '.
              'Slow! But also very reassuring!'),
          ),
        ));
  }

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

    $mode = $args->getArg('mode');
    if (!$mode) {
      throw new PhutilArgumentUsageException(
        pht('Choose an archival mode with --mode.'));
    }

    $valid_modes = array(
      'plain',
      'compress',
    );

    $valid_modes = array_fuse($valid_modes);
    if (empty($valid_modes[$mode])) {
      throw new PhutilArgumentUsageException(
        pht(
          'Unknown mode "%s". Valid modes are: %s.',
          $mode,
          implode(', ', $valid_modes)));
    }

    $log_table = new HarbormasterBuildLog();

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Run with an explicit mode: `./bin/phabricator harbormaster archive-logs --mode compress` (or --mode plain).
  2. Check the command's help (`--help`) for the current flag names.
  3. Fix the wrapper/cron line so the flag survives shell quoting.

Example fix

# before
./bin/phabricator harbormaster archive-logs

# after
./bin/phabricator harbormaster archive-logs --mode compress
Defensive patterns

Strategy: validation

Validate before calling

$mode = $argv['mode'] ?? null;
if ($mode === null || $mode === '') {
  fwrite(STDERR, "Usage: archive-logs --mode plain|compress\n");
  exit(64);
}

Type guard

function isValidArchiveMode($mode) {
  return in_array($mode, array('plain', 'compress'), true);
}

Try / catch

try {
  runArchiveLogs($args);
} catch (PhutilArgumentUsageException $e) {
  fwrite(STDERR, $e->getMessage()."\n");
  exit(64); // conventional usage-error exit code
}

Prevention

When it happens

Trigger: Running `./bin/phabricator harbormaster archive-logs` (or the arc/binary equivalent) with no arguments; running it with only auxiliary flags like --details or --verbose; a wrapper script/cron that drops the flag.

Common situations: First-time use of the archival command from docs; cron entries written before the flag was added; copy-pasting a command that used an older syntax.

Related errors


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