{"record":{"id":"abba2c9a26bdb96c","repo":"phacility/phabricator","slug":"use-constraint-flags-like-id-or-class-to","errorCode":null,"errorMessage":"Use constraint flags (like \"--id\" or \"--class\") to select which tasks to affect. Use \"--help\" for a list of supported constraint flags.","messagePattern":"Use constraint flags \\(like \"--id\" or \"--class\"\\) to select which tasks to affect\\. Use \"--help\" for a list of supported constraint flags\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php","lineNumber":144,"sourceCode":"              'specified \"--max-failures\".'));\n        }\n      }\n    }\n\n    if (($min_priority !== null) || ($max_priority !== null)) {\n      $any_constraints = true;\n      if (($min_priority !== null) && ($max_priority !== null)) {\n        if ($min_priority > $max_priority) {\n          throw new PhutilArgumentUsageException(\n            pht(\n              'Specified \"--min-priority\" may not be larger than '.\n              'specified \"--max-priority\".'));\n        }\n      }\n    }\n\n    if (!$any_constraints) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Use constraint flags (like \"--id\" or \"--class\") to select which '.\n          'tasks to affect. Use \"--help\" for a list of supported constraint '.\n          'flags.'));\n    }\n\n    if ($limit !== null) {\n      $limit = (int)$limit;\n      if ($limit <= 0) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'Specified \"--limit\" must be a positive integer.'));\n      }\n    }\n\n    $active_query = new PhabricatorWorkerActiveTaskQuery();\n    $archive_query = new PhabricatorWorkerArchiveTaskQuery();\n","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php#L126-L162","documentation":"Thrown when a `bin/worker` management subcommand is invoked with no task-selection constraint at all. Because these commands mutate tasks (retry, archive, reprioritize, etc.), Phabricator requires at least one of `--id`, `--class`, `--active`/`--archived`, `--min-failures`/`--max-failures`, `--min-priority`/`--max-priority`, `--object`, `--container`, or `--limit`-adjacent constraints, so an accidental 'affect everything' invocation cannot happen. The check counts any constraint flag before running the query.","triggerScenarios":"Bare invocations like `./bin/worker retry`, `./bin/worker archive`, or `./bin/worker priority --priority 1000` with no selector. Note that `--priority` and `--limit` alone do not count as constraints.","commonSituations":"Operators expecting an interactive prompt or a default scope; scripts whose constraint variables expand to empty strings; running the command expecting `--help` output; forgetting that mutation commands never default to 'all tasks'.","solutions":["Add at least one constraint, e.g. `--class PhabricatorMailWorker` or `--id 123`","Run `./bin/worker <command> --help` to list the supported constraint flags","Intentionally target everything with the broad constraint pair `--active --archived` minus the conflicting one, e.g. run twice with `--active` then `--archived` plus `--class`"],"exampleFix":"# before\n./bin/worker retry\n\n# after\n./bin/worker retry --class PhabricatorWorkerBulkJobWorker --active","handlingStrategy":"validation","validationCode":"$constraintFlags = array_filter(array(\n  '--id' => $ids, '--class' => $class,\n  '--active' => $active, '--archived' => $archived,\n));\nif (empty($constraintFlags)) {\n  fwrite(STDERR, \"Refusing to run a worker command with no constraints.\\n\");\n  exit(1);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always author worker mutation commands with an explicit scope; never rely on a default","Dry-run selection with `bin/worker show` constraints before mutation commands in automation"],"tags":["phabricator","cli","worker-queue","missing-required-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}