{"record":{"id":"85bbd1fdd5ea8a81","repo":"phacility/phabricator","slug":"specified-limit-must-be-a-positive-integer","errorCode":null,"errorMessage":"Specified \"--limit\" must be a positive integer.","messagePattern":"Specified \"--limit\" must be a positive integer\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php","lineNumber":154,"sourceCode":"            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\n    if ($ids) {\n      $active_query = $active_query->withIDs($ids);\n      $archive_query = $archive_query->withIDs($ids);\n    }\n\n    if ($class) {\n      $class_array = array($class);\n      $active_query = $active_query->withClassNames($class_array);\n      $archive_query = $archive_query->withClassNames($class_array);\n    }","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php#L136-L172","documentation":"Thrown when `--limit` is provided to a worker management command but is not a positive integer after casting. The limit caps how many matching tasks the command affects; zero or negative limits are meaningless (and PHP casts non-numeric strings to 0), so the workflow validates it explicitly before executing the task queries.","triggerScenarios":"`./bin/worker archive --limit 0 --class X`, `--limit -1`, or `--limit abc` (casts to 0). Fires only when the flag is present; omitting `--limit` entirely is fine.","commonSituations":"Scripts computing a limit from a counter that can legitimately be zero (empty result set upstream); shell variables that expand to empty; reusing a `--limit` value that was valid for pagination elsewhere but got decremented past zero.","solutions":["Pass a positive integer such as `--limit 100`","Skip the flag entirely when no cap is wanted","In automation, omit `--limit` when the computed value would be <= 0 instead of passing it through"],"exampleFix":"# before\n./bin/worker archive --limit 0 --class X\n\n# after\n./bin/worker archive --class X","handlingStrategy":"validation","validationCode":"$args = array('./bin/worker', $subcommand);\nif ($limit !== null) {\n  $limit = (int)$limit;\n  if ($limit <= 0) {\n    unset($limit); // omit the flag rather than fail\n  } else {\n    $args[] = '--limit='.$limit;\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Skip --limit when the computed cap is zero or negative instead of passing it","Validate numeric flags against a positive-int regex before building commands"],"tags":["phabricator","cli","worker-queue","argument-validation","limit"],"backgroundTag":"invalid-cli-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}