{"record":{"id":"fb138a286e61e849","repo":"phacility/phabricator","slug":"specify-a-command-to-run","errorCode":null,"errorMessage":"Specify a command to run.","messagePattern":"Specify a command to run\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/drydock/management/DrydockManagementCommandWorkflow.php","lineNumber":35,"sourceCode":"          array(\n            'name' => 'argv',\n            'wildcard' => true,\n            'help' => pht('Command to execute.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $lease_id = $args->getArg('lease');\n    if (!$lease_id) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Use \"--lease\" to specify a lease.'));\n    }\n\n    $argv = $args->getArg('argv');\n    if (!$argv) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify a command to run.'));\n    }\n\n    $lease = id(new DrydockLeaseQuery())\n      ->setViewer($this->getViewer())\n      ->withIDs(array($lease_id))\n      ->executeOne();\n    if (!$lease) {\n      throw new Exception(\n        pht(\n          'Unable to load lease with ID \"%s\"!',\n          $lease_id));\n    }\n\n    // TODO: Check lease state, etc.\n\n    $interface = $lease->getInterface(DrydockCommandInterface::INTERFACE_TYPE);","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/management/DrydockManagementCommandWorkflow.php#L17-L53","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nbin/drydock command --lease 42\n\n# after\nbin/drydock command --lease 42 -- ls -la /","handlingStrategy":"validation","validationCode":"if (count($argv) === 0) {\n  throw new InvalidArgumentException('No command given for drydock command.');\n}\n$cmd = array_merge(\n  array('bin/drydock', 'command', '--lease', (string)$lease_id, '--'),\n  $argv);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["drydock","phabricator","cli","usage","argv"],"backgroundTag":"missing-cli-argument","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}