phacility/phabricator · error · PhutilArgumentUsageException
Specify a command to run.
Error message
Specify a command to run.
What it means
A PhutilArgumentUsageException from `bin/drydock command` when --lease is provided but no command (argv) follows. The workflow executes an arbitrary command on the leased resource via its command interface, so an empty wildcard argument list is rejected before the lease is even loaded.
Source
Thrown at src/applications/drydock/management/DrydockManagementCommandWorkflow.php:35
array(
'name' => 'argv',
'wildcard' => true,
'help' => pht('Command to execute.'),
),
));
}
public function execute(PhutilArgumentParser $args) {
$lease_id = $args->getArg('lease');
if (!$lease_id) {
throw new PhutilArgumentUsageException(
pht(
'Use "--lease" to specify a lease.'));
}
$argv = $args->getArg('argv');
if (!$argv) {
throw new PhutilArgumentUsageException(
pht(
'Specify a command to run.'));
}
$lease = id(new DrydockLeaseQuery())
->setViewer($this->getViewer())
->withIDs(array($lease_id))
->executeOne();
if (!$lease) {
throw new Exception(
pht(
'Unable to load lease with ID "%s"!',
$lease_id));
}
// TODO: Check lease state, etc.
$interface = $lease->getInterface(DrydockCommandInterface::INTERFACE_TYPE);View on GitHub (pinned to 5720a38cfe)
Solutions
- Append the command and its arguments after a `--` separator: `bin/drydock command --lease 42 -- ls -la`.
- In scripts, verify the argv array is non-empty before invoking the workflow.
Example fix
# before bin/drydock command --lease 42 # after bin/drydock command --lease 42 -- ls -la /
Defensive patterns
Strategy: validation
Validate before calling
if (count($argv) === 0) {
throw new InvalidArgumentException('No command given for drydock command.');
}
$cmd = array_merge(
array('bin/drydock', 'command', '--lease', (string)$lease_id, '--'),
$argv); Prevention
- Always terminate flags with `--` before the command so argv is parsed as command words.
- When building argv programmatically, fail fast if the array is empty.
When it happens
Trigger: Running `bin/drydock command --lease 42` with nothing after the flag, or putting the command before the flags so PhutilArgumentParser consumes it as an option value.
Common situations: Quoting mistakes in scripts that build argv dynamically and end up with an empty array; forgetting the trailing `--` separator so the intended command is parsed as flags.
Related errors
- Use "--lease" to specify a lease.
- Specify a resource type with "--type".
- You must specify the path to a public keyfile with %s.
- You must specify the path to a pkcs8 keyfile with %s.
- You must specify the username of the account to recover.
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/fb138a286e61e849.
Report an issue: GitHub.