{"record":{"id":"ca9a96625f64756d","repo":"phacility/phabricator","slug":"use-lease-to-specify-a-lease","errorCode":null,"errorMessage":"Use \"--lease\" to specify a lease.","messagePattern":"Use \"--lease\" to specify a lease\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"error","filePath":"src/applications/drydock/management/DrydockManagementCommandWorkflow.php","lineNumber":28,"sourceCode":"      ->setArguments(\n        array(\n          array(\n            'name' => 'lease',\n            'param' => 'id',\n            'help' => pht('Lease ID.'),\n          ),\n          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(","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/management/DrydockManagementCommandWorkflow.php#L10-L46","documentation":"A PhutilArgumentUsageException raised by `bin/drydock command` when the --lease flag is omitted. The workflow needs an existing lease to route the command through, so it immediately aborts with a usage hint before touching the database. It is purely a command-line usage error, not a state problem.","triggerScenarios":"Running `bin/drydock command -- <cmd>` (or with only other flags) without --lease <id>. getArg('lease') is falsy and the workflow throws.","commonSituations":"Copy-pasting a command template and dropping the flag; assuming the workflow picks the most recent lease; scripting the CLI and an empty $LEASE_ID shell variable expands to nothing.","solutions":["Add --lease <id> with the numeric ID of an acquired Drydock lease, e.g. `bin/drydock command --lease 42 -- ls /`.","If the lease ID comes from a script, guard the invocation so it fails clearly when the variable is empty."],"exampleFix":"# before\nbin/drydock command -- git status\n\n# after\nbin/drydock command --lease 42 -- git status","handlingStrategy":"validation","validationCode":"#!/bin/sh\n[ -n \"$LEASE_ID\" ] || { echo 'LEASE_ID is empty; refusing to run drydock command' >&2; exit 2; }\nexec bin/drydock command --lease \"$LEASE_ID\" -- \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wrap `bin/drydock command` in a script template that always includes --lease.","Treat a non-zero exit with a usage message as a caller bug — fix the invocation, do not retry it."],"tags":["drydock","phabricator","cli","usage","lease"],"backgroundTag":"missing-cli-flag","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}