phacility/phabricator · warning · PhutilArgumentUsageException

Lease "%s" does not exist.

Error message

Lease "%s" does not exist.

What it means

Thrown by `drydock release-lease` when one of the requested `--id` values does not match any lease returned by the query. Importantly the query is pre-filtered to statuses whose status object reports `canRelease()` (see getReleaseableLeaseStatuses), so a lease that exists in the database but is in a non-releaseable status (for example already RELEASED) is invisible to the query and is reported as "does not exist" just like a nonexistent ID. This is a PhutilArgumentUsageException: nothing is released, not even the other valid IDs.

Source

Thrown at src/applications/drydock/management/DrydockManagementReleaseLeaseWorkflow.php:56

    $statuses = $this->getReleaseableLeaseStatuses();

    $query = id(new DrydockLeaseQuery())
      ->setViewer($viewer)
      ->withStatuses(mpull($statuses, 'getKey'));

    if ($ids) {
      $query->withIDs($ids);
    }

    $leases = $query->execute();

    if ($ids) {
      $id_map = mpull($leases, null, 'getID');

      foreach ($ids as $id) {
        $lease = idx($id_map, $id);
        if (!$lease) {
          throw new PhutilArgumentUsageException(
            pht('Lease "%s" does not exist.', $id));
        }
      }

      $leases = array_select_keys($id_map, $ids);
    }

    if (!$leases) {
      echo tsprintf(
        "%s\n",
        pht('No leases selected for release.'));

      return 0;
    }

    $drydock_phid = id(new PhabricatorDrydockApplication())->getPHID();

    PhabricatorWorker::setRunAllTasksInProcess(true);

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. List the actual releaseable leases to get valid IDs: `./bin/drydock lease --status active` (or query via DrydockLeaseSearchQuery/`drydock.lease.search`) and re-run with those IDs
  2. If the lease exists but was already released, no action is needed — verify with the lease UI or query
  3. Check for leading zeros / whitespace or shell quoting issues around the ID list
  4. Run with `--all` if the intent is to release every releaseable lease regardless of ID

Example fix

// before
$ ./bin/drydock release-lease --id 9999
Usage Exception: Lease "9999" does not exist.

// after
$ ./bin/drydock lease --status active   # find real IDs
$ ./bin/drydock release-lease --id 42
Defensive patterns

Strategy: validation

Validate before calling

// Verify IDs exist AND are releaseable before running the workflow:
$statuses = DrydockLeaseStatus::getAllStatuses();
$releaseable = array();
foreach ($statuses as $key => $status) {
  if (DrydockLeaseStatus::newStatusObject($status)->canRelease()) {
    $releaseable[] = $key;
  }
}
$leases = id(new DrydockLeaseQuery())
  ->setViewer($viewer)
  ->withIDs($ids)
  ->withStatuses($releaseable)
  ->execute();
if (count($leases) !== count($ids)) {
  // report which IDs are missing/non-releaseable before invoking release
}

Try / catch

catch (PhutilArgumentUsageException $ex) { the message names the bad ID; diff it against the releaseable-lease query results and either drop it or use --all }

Prevention

When it happens

Trigger: Passing a typo'd or guessed lease ID; referencing a lease that was already released (its status no longer canRelease()); referencing a lease whose status is not releaseable (e.g. broken/destroyed states excluded by the filter); passing an ID visible only to a different viewer (the query runs with the script viewer's permissions).

Common situations: Re-running an old release command from shell history after the leases were already freed; copy/paste of lease IDs from a stale web UI or log; IDs taken from a different Drydock installation.

Related errors


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