{"record":{"id":"b482ad96172f1041","repo":"phacility/phabricator","slug":"choose-an-archival-mode-with-mode","errorCode":null,"errorMessage":"Choose an archival mode with --mode.","messagePattern":"Choose an archival mode with --mode\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/harbormaster/management/HarbormasterManagementArchiveLogsWorkflow.php","lineNumber":34,"sourceCode":"            'help' => pht(\n              'Use \"plain\" to remove encoding, or \"compress\" to compress '.\n              'logs.'),\n          ),\n          array(\n            'name' => 'details',\n            'help' => pht(\n              'Show more details about operations as they are performed. '.\n              'Slow! But also very reassuring!'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $mode = $args->getArg('mode');\n    if (!$mode) {\n      throw new PhutilArgumentUsageException(\n        pht('Choose an archival mode with --mode.'));\n    }\n\n    $valid_modes = array(\n      'plain',\n      'compress',\n    );\n\n    $valid_modes = array_fuse($valid_modes);\n    if (empty($valid_modes[$mode])) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Unknown mode \"%s\". Valid modes are: %s.',\n          $mode,\n          implode(', ', $valid_modes)));\n    }\n\n    $log_table = new HarbormasterBuildLog();","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/management/HarbormasterManagementArchiveLogsWorkflow.php#L16-L52","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run with an explicit mode: `./bin/phabricator harbormaster archive-logs --mode compress` (or --mode plain).","Check the command's help (`--help`) for the current flag names.","Fix the wrapper/cron line so the flag survives shell quoting."],"exampleFix":"# before\n./bin/phabricator harbormaster archive-logs\n\n# after\n./bin/phabricator harbormaster archive-logs --mode compress","handlingStrategy":"validation","validationCode":"$mode = $argv['mode'] ?? null;\nif ($mode === null || $mode === '') {\n  fwrite(STDERR, \"Usage: archive-logs --mode plain|compress\\n\");\n  exit(64);\n}","typeGuard":"function isValidArchiveMode($mode) {\n  return in_array($mode, array('plain', 'compress'), true);\n}","tryCatchPattern":"try {\n  runArchiveLogs($args);\n} catch (PhutilArgumentUsageException $e) {\n  fwrite(STDERR, $e->getMessage().\"\\n\");\n  exit(64); // conventional usage-error exit code\n}","preventionTips":["Read --help before running harbormaster management commands for the first time.","In cron/wrapper scripts, always pass the full flag set explicitly and test the wrapper manually once."],"tags":["harbormaster","cli","usage-error","log-archival"],"backgroundTag":"cli-argument-validation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}