phacility/phabricator · error · Exception

Unable to load lease with ID "%s"!

Error message

Unable to load lease with ID "%s"!

What it means

Thrown by `bin/drydock command` when a DrydockLeaseQuery for the given --lease ID returns no row. Either no lease with that numeric ID exists, or the lease is not visible to the viewer the management workflow uses. Note the workflow then goes straight to getInterface(DrydockCommandInterface::INTERFACE_TYPE), so leases of resource types without a command interface are also unusable here.

Source

Thrown at src/applications/drydock/management/DrydockManagementCommandWorkflow.php:45

    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);

    list($stdout, $stderr) = call_user_func_array(
      array($interface, 'execx'),
      array('%Ls', $argv));

    fwrite(STDOUT, $stdout);
    fwrite(STDERR, $stderr);

    return 0;
  }

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Confirm the lease ID in the Drydock web UI (Leases list) or database and pass the numeric ID.
  2. Remember it must be the lease ID, not the resource ID and not a PHID.
  3. If the lease should exist, check it has not been released/destroyed and is visible to the viewer running the CLI.

Example fix

# before (9999 does not exist / is a resource ID)
bin/drydock command --lease 9999 -- git status

# after (actual lease ID from the Drydock lease UI)
bin/drydock command --lease 42 -- git status
Defensive patterns

Strategy: validation

Validate before calling

$lease = id(new DrydockLeaseQuery())
  ->setViewer($viewer)
  ->withIDs(array($lease_id))
  ->executeOne();
if (!$lease) {
  throw new InvalidArgumentException("No lease with ID {$lease_id}.");
}

Prevention

When it happens

Trigger: `bin/drydock command --lease 9999 -- ls` where lease 9999 does not exist; passing a PHID or callsign instead of the numeric lease ID; referencing a lease the acting admin viewer cannot see.

Common situations: Reading the resource ID instead of the lease ID from the Drydock UI; stale lease IDs after leases were released and reclaimed; typos in automation scripts.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/d89581b54dd07deb. Report an issue: GitHub.