{"record":{"id":"d6aed7cc8284fd42","repo":"phacility/phabricator","slug":"unknown-mode-s-valid-modes-are-s","errorCode":null,"errorMessage":"Unknown mode \"%s\". Valid modes are: %s.","messagePattern":"Unknown mode \"(.+?)\"\\. Valid modes are: (.+?)\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/harbormaster/management/HarbormasterManagementArchiveLogsWorkflow.php","lineNumber":45,"sourceCode":"  }\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();\n    $logs = new LiskMigrationIterator($log_table);\n\n    $show_details = $args->getArg('details');\n\n    if ($show_details) {\n      $total_old = 0;\n      $total_new = 0;\n    }\n\n    foreach ($logs as $log) {\n      echo tsprintf(","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/management/HarbormasterManagementArchiveLogsWorkflow.php#L27-L63","documentation":"The archive-logs workflow got a --mode value that is not in the valid set. Valid modes are exactly 'plain' and 'compress' (fused into a set before checking), so values like 'compressed', 'gzip', 'zstd', or 'PLAIN' fail here with the valid list in the message.","triggerScenarios":"Passing --mode compressed, --mode gzip, --mode zlib, or any uppercase/misspelled variant; assuming the mode matches the log chunk encoding constant names instead of the CLI keywords; scripts written against different tooling.","commonSituations":"Guessing flag values instead of reading --help; migrating from a custom archival script whose mode names differ.","solutions":["Use exactly `--mode plain` (store chunks uncompressed) or `--mode compress` (store chunks compressed).","Run with --help to confirm the accepted values on your version."],"exampleFix":"# before\n./bin/phabricator harbormaster archive-logs --mode compressed\n\n# after\n./bin/phabricaster archive-logs --mode compress","handlingStrategy":"validation","validationCode":"$valid = array('plain', 'compress');\nif (!in_array($mode, $valid, true)) {\n  throw new PhutilArgumentUsageException(\n    'Unknown mode. Valid modes are: '.implode(', ', $valid));\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);\n}","preventionTips":["Match flag values byte-for-byte against the list in the error message / --help output; the check is case-sensitive.","Pin automation to a documented set of CLI values and re-validate after Phabricator upgrades."],"tags":["harbormaster","cli","usage-error","invalid-argument","log-archival"],"backgroundTag":"cli-argument-validation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}