{"record":{"id":"eeee751caea43586","repo":"phacility/phabricator","slug":"priority-must-be-a-positive-integer","errorCode":null,"errorMessage":"Priority must be a positive integer.","messagePattern":"Priority must be a positive integer\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementPriorityWorkflow.php","lineNumber":39,"sourceCode":"                'Set tasks to this priority. Tasks with a smaller priority '.\n                'value execute before tasks with a larger priority value.'),\n            ),\n          ),\n          $this->getTaskSelectionArguments()));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $new_priority = $args->getArg('priority');\n\n    if ($new_priority === null) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Select a new priority for selected tasks with \"--priority\".'));\n    }\n\n    $new_priority = (int)$new_priority;\n    if ($new_priority <= 0) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Priority must be a positive integer.'));\n    }\n\n    $tasks = $this->loadTasks($args);\n\n    if (!$tasks) {\n      $this->logWarn(\n        pht('NO TASKS'),\n        pht('No tasks selected to reprioritize.'));\n\n      return 0;\n    }\n\n    $priority_count = 0;\n    foreach ($tasks as $task) {\n      $can_reprioritize = !$task->isArchived();\n      if (!$can_reprioritize) {","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementPriorityWorkflow.php#L21-L57","documentation":"Thrown by the `bin/worker priority` management workflow (PhabricatorWorkerManagementPriorityWorkflow) when the value passed via `--priority` is not a positive integer. The command casts the argument to int and rejects anything <= 0 because task priority is stored as an unsigned value; zero or negative priorities would be meaningless for worker queue ordering. It is a PhutilArgumentUsageException, meaning the CLI invocation itself is malformed, not that any task failed.","triggerScenarios":"Running `./bin/worker priority --priority 0 --id 123`, `--priority -5`, or a non-numeric value like `--priority abc` (PHP's `(int)` cast turns it into 0). Also triggered by omitting a usable value after the flag is parsed as an empty string. Requires `--priority` to be non-null first (a null value throws the separate 'Select a new priority' error).","commonSituations":"Automation scripts that compute a priority from another variable which can be 0 or negative; shell scripts passing an unset environment variable that expands to empty; typos like `--priority=O` (letter O). Common when operators retask queues during incident response and pass a computed value without validating it.","solutions":["Re-run with a positive integer, e.g. `./bin/worker priority --priority 1000 --id 42`","If the value comes from a script, clamp/validate it before invoking the CLI: reject or default values <= 0","Check the exact spelling of the flag (`--priority`) and that its value is numeric, not empty or alphabetic"],"exampleFix":"# before\n./bin/worker priority --priority 0 --id 42\n\n# after\n./bin/worker priority --priority 1000 --id 42","handlingStrategy":"validation","validationCode":"// before shelling out to bin/worker priority\n$newPriority = (int)$configured_priority;\nif ($new_priority <= 0) {\n  throw new InvalidArgumentException(\n    '--priority must be a positive integer, got: '.$configured_priority);\n}\nexec(sprintf(\n  './bin/worker priority --priority %d --id %d',\n  $new_priority,\n  $task_id,\n));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat priority as unsigned in any script that computes it; clamp or reject <= 0 before invoking the CLI","Never pass shell variables unquoted or unexpanded-empty into --priority","Run `./bin/worker priority --help` once in CI for scripts to pin the expected flag surface"],"tags":["phabricator","cli","worker-queue","argument-validation","priority"],"backgroundTag":"invalid-cli-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}