{"record":{"id":"f76ba7fad241ad37","repo":"phacility/phabricator","slug":"use-one-of-id-or-active-to-select-builds","errorCode":null,"errorMessage":"Use one of \"--id\" or \"--active\" to select builds, but not both.","messagePattern":"Use one of \"--id\" or \"--active\" to select builds, but not both\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/harbormaster/management/HarbormasterManagementRestartWorkflow.php","lineNumber":37,"sourceCode":"            'help' => pht('Select one or more builds by ID.'),\n          ),\n          array(\n            'name' => 'active',\n            'help' => pht('Select all active builds.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n    $ids = $args->getArg('id');\n    $active = $args->getArg('active');\n\n    if (!$ids && !$active) {\n      throw new PhutilArgumentUsageException(\n        pht('Use \"--id\" or \"--active\" to select builds.'));\n    } if ($ids && $active) {\n      throw new PhutilArgumentUsageException(\n        pht('Use one of \"--id\" or \"--active\" to select builds, but not both.'));\n    }\n\n    $query = id(new HarbormasterBuildQuery())\n      ->setViewer($viewer);\n    if ($ids) {\n      $query->withIDs($ids);\n    } else {\n      $query->withBuildStatuses(\n        HarbormasterBuildStatus::getActiveStatusConstants());\n    }\n    $builds = $query->execute();\n\n    $count = count($builds);\n    if (!$count) {\n      $this->logSkip(\n        pht('SKIP'),\n        pht('No builds to restart.'));","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/management/HarbormasterManagementRestartWorkflow.php#L19-L55","documentation":"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.","triggerScenarios":"Running 'bin/harbormaster restart --id 15 --active'.","commonSituations":"Scripts that append --active 'for safety' to every invocation; combining flags from different documentation examples.","solutions":["Keep only the --id flags for a targeted restart","Keep only --active to restart all active builds","Encode 'exactly one of --id/--active' logic in automation scripts"],"exampleFix":"# before\n$ bin/harbormaster restart --id 15 --active\n# after\n$ bin/harbormaster restart --id 15","handlingStrategy":"validation","validationCode":"# shell wrapper: exactly one of --id / --active\nif [ -n ${BUILD_IDS:-} ] && [ ${RESTART_ACTIVE:-0} -eq 1 ]; then\n  echo 'error: use --id or --active, not both' >&2\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never append --active 'for safety' to scripts that already pass --id","Encode xor logic between selection flags in wrapper scripts"],"tags":["harbormaster","phabricator","cli","conflicting-options","build-restart"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}