phacility/phabricator · error · PhutilArgumentUsageException
Value provided to "--count" must be a nonzero, positive…
Error message
Value provided to "--count" must be a nonzero, positive number.
What it means
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.
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.
Example fix
# before bin/drydock lease --type host --count 0 # after bin/drydock lease --type host --count 3
Defensive patterns
Strategy: validation
Validate before calling
$count = (int)$count;
if ($count < 1) {
throw new InvalidArgumentException(
'--count must be a positive integer, got '.$count);
} Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Unable to parse argument to "--until".
- Blueprint " " could not be loaded. Try a blueprint ID or…
- Blueprint " " is specified more than once (as " " and " ").
- Blueprint type " " is unrecognized. Valid types are: .
- Lease has already been destroyed!
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/8820b2c4f1157448.
Report an issue: GitHub.
Appendix: source
Thrown at src/applications/drydock/management/DrydockManagementLeaseWorkflow.php:66
if (!phutil_nonempty_string($resource_type)) {
throw new PhutilArgumentUsageException(
pht(
'Specify a resource type with "--type".'));
}
$until = $args->getArg('until');
if (phutil_nonempty_string($until)) {
$until = strtotime($until);
if ($until <= 0) {
throw new PhutilArgumentUsageException(
pht(
'Unable to parse argument to "--until".'));
}
}
$count = $args->getArgAsInteger('count');
if ($count < 1) {
throw new PhutilArgumentUsageException(
pht(
'Value provided to "--count" must be a nonzero, positive '.
'number.'));
}
$attributes_file = $args->getArg('attributes');
if (phutil_nonempty_string($attributes_file)) {
if ($attributes_file == '-') {
echo tsprintf(
"%s\n",
pht('Reading JSON attributes from stdin...'));
$data = file_get_contents('php://stdin');
} else {
$data = Filesystem::readFile($attributes_file);
}
$attributes = phutil_json_decode($data);
} else {View on GitHub (pinned to 5720a38cfe)