{"record":{"id":"0e6b00093cdf3d4d","repo":"phacility/phabricator","slug":"you-can-not-specify-both-active-and-archive","errorCode":null,"errorMessage":"You can not specify both \"--active\" and \"--archived\" tasks: no tasks can match both constraints.","messagePattern":"You can not specify both \"--active\" and \"--archived\" tasks: no tasks can match both constraints\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php","lineNumber":98,"sourceCode":"\n    $min_priority = $args->getArg('min-priority');\n    $max_priority = $args->getArg('max-priority');\n\n    $limit = $args->getArg('limit');\n\n    $any_constraints = false;\n    if ($ids) {\n      $any_constraints = true;\n    }\n\n    if ($class) {\n      $any_constraints = true;\n    }\n\n    if ($active || $archived) {\n      $any_constraints = true;\n      if ($active && $archived) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'You can not specify both \"--active\" and \"--archived\" tasks: '.\n            'no tasks can match both constraints.'));\n      }\n    }\n\n    if ($container_names) {\n      $any_constraints = true;\n      $container_phids = $this->loadObjectPHIDsFromArguments($container_names);\n    } else {\n      $container_phids = array();\n    }\n\n    if ($object_names) {\n      $any_constraints = true;\n      $object_phids = $this->loadObjectPHIDsFromArguments($object_names);\n    } else {\n      $object_phids = array();","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php#L80-L116","documentation":"Thrown by Phabricator's worker management workflows (`bin/worker ...`) when the command line supplies both `--active` and `--archived` at the same time. A task exists in exactly one of the two tables (active vs archived), so the two flags produce an empty, contradictory selection and Phabricator refuses to run rather than silently affecting nothing. It is a PhutilArgumentUsageException raised during constraint parsing, before any query executes.","triggerScenarios":"Any invocation such as `./bin/worker retry --active --archived --class SomeTaskClass`, `./bin/worker archive --active --archived`, or `--id 5 --active --archived`. Both flags set to true (even as `--active --archived` with no values) triggers it.","commonSituations":"Copy-pasting a previously working command and appending flags without removing the old one; scripts that concatenate optional flags into one string and end up including both; operators assuming `--active --archived` means 'everything'.","solutions":["Pass only one of the two flags: `--active` for queued/leased tasks, `--archived` for completed or failed tasks","Omit both flags to search both sets when combined with other constraints like `--id` or `--class`","Audit wrapper scripts that build the flag list dynamically and guard against emitting both"],"exampleFix":"# before\n./bin/worker retry --active --archived --class PhabricatorMailerWorker\n\n# after\n./bin/worker retry --archived --class PhabricatorMailerWorker","handlingStrategy":"validation","validationCode":"$flags = array();\nif ($include_active) { $flags[] = '--active'; }\nif ($include_archived) { $flags[] = '--archived'; }\nif ($include_active && $include_archived) {\n  throw new InvalidArgumentException(\n    '--active and --archived are mutually exclusive');\n}\n$cmd = './bin/worker '.implode(' ', array_merge([$subcommand], $flags));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Model the two flags as a single tri-state selector ('active'|'archived'|'both') in wrapper scripts so both can never be emitted","Keep a reviewed library of worker commands rather than ad-hoc concatenation"],"tags":["phabricator","cli","worker-queue","mutually-exclusive-flags"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}