{"record":{"id":"8820b2c4f1157448","repo":"phacility/phabricator","slug":"value-provided-to-count-must-be-a-nonzero-pos","errorCode":null,"errorMessage":"Value provided to \"--count\" must be a nonzero, positive number.","messagePattern":"Value provided to \"--count\" must be a nonzero, positive number\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/drydock/management/DrydockManagementLeaseWorkflow.php","lineNumber":66,"sourceCode":"    if (!phutil_nonempty_string($resource_type)) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify a resource type with \"--type\".'));\n    }\n\n    $until = $args->getArg('until');\n    if (phutil_nonempty_string($until)) {\n      $until = strtotime($until);\n      if ($until <= 0) {\n        throw new PhutilArgumentUsageException(\n          pht(\n            'Unable to parse argument to \"--until\".'));\n      }\n    }\n\n    $count = $args->getArgAsInteger('count');\n    if ($count < 1) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Value provided to \"--count\" must be a nonzero, positive '.\n          'number.'));\n    }\n\n    $attributes_file = $args->getArg('attributes');\n    if (phutil_nonempty_string($attributes_file)) {\n      if ($attributes_file == '-') {\n        echo tsprintf(\n          \"%s\\n\",\n          pht('Reading JSON attributes from stdin...'));\n        $data = file_get_contents('php://stdin');\n      } else {\n        $data = Filesystem::readFile($attributes_file);\n      }\n\n      $attributes = phutil_json_decode($data);\n    } else {","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/management/DrydockManagementLeaseWorkflow.php#L48-L84","documentation":"A PhutilArgumentUsageException from `bin/drydock lease` when --count parses (via getArgAsInteger) to a value below 1. --count sets how many identical leases the single invocation creates (default 1); zero or negative counts are meaningless and rejected before any lease is created.","triggerScenarios":"`bin/drydock lease --type host --count 0`, `--count -5`, or a non-numeric value that getArgAsInteger coerces/rejects; a computed count in a script that evaluates to 0 when a list is empty.","commonSituations":"Fan-out scripts computing count = number of items and passing 0 for an empty batch; treating --count as a lease ID or offset by mistake.","solutions":["Pass a positive integer, e.g. `--count 3` to acquire three identical leases.","Skip the invocation entirely when the computed count is 0 rather than calling with the flag."],"exampleFix":"# before\nbin/drydock lease --type host --count 0\n\n# after\nbin/drydock lease --type host --count 3","handlingStrategy":"validation","validationCode":"$count = (int)$count;\nif ($count < 1) {\n  throw new InvalidArgumentException(\n    '--count must be a positive integer, got '.$count);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Skip the CLI call when a computed count is zero (empty batch) instead of passing --count 0.","Do not use --count to carry other numbers (IDs, offsets) — it multiplies leases."],"tags":["drydock","phabricator","cli","count","validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}