phacility/phabricator · warning · PhutilArgumentUsageException

Resource "%s" does not exist.

Error message

Resource "%s" does not exist.

What it means

Thrown by `drydock release-resource` when a requested `--id` does not match a resource from the query. Two distinct causes produce it: (1) the query is filtered to statuses where the status object's `canRelease()` is true, so an existing-but-already-released (or otherwise non-releaseable) resource is invisible and reported as nonexistent; (2) a latent bug in this revision — the lookup uses `idx($resources, $id)` on the raw result list instead of the ID-keyed map `idx($id_map, $id)` — so a resource that genuinely exists can be falsely reported missing whenever its list position does not equal its ID (for example ID 7 sitting at list index 0). Nothing is released when this throws.

Source

Thrown at src/applications/drydock/management/DrydockManagementReleaseResourceWorkflow.php:55

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

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

    $resources = $query->execute();

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

      foreach ($ids as $id) {
        $resource = idx($resources, $id);

        if (!$resource) {
          throw new PhutilArgumentUsageException(
            pht('Resource "%s" does not exist.', $id));
        }
      }

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

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

      return 0;
    }

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

    PhabricatorWorker::setRunAllTasksInProcess(true);

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Confirm the resource really exists and is releaseable: check the Drydock resource UI or run the resource query, then re-run with correct IDs
  2. If the resource exists but the command still claims it does not, you are hitting the `idx($resources, $id)` vs `idx($id_map, $id)` bug — use `--all`, or patch the lookup to use the ID map
  3. If it was already released, no action is needed
  4. Upgrade the Phabricator checkout; later revisions fix the id_map lookup

Example fix

// before (DrydockManagementReleaseResourceWorkflow.php)
$resource = idx($resources, $id);
if (!$resource) {
  throw new PhutilArgumentUsageException(
    pht('Resource "%s" does not exist.', $id));
}

// after
$resource = idx($id_map, $id);
if (!$resource) {
  throw new PhutilArgumentUsageException(
    pht('Resource "%s" does not exist.', $id));
}
Defensive patterns

Strategy: validation

Validate before calling

// Verify IDs against releaseable resources before running:
$releaseable = array();
foreach (DrydockResourceStatus::getAllStatuses() as $key => $status) {
  if (DrydockResourceStatus::newStatusObject($status)->canRelease()) {
    $releaseable[] = $key;
  }
}
$resources = id(new DrydockResourceQuery())
  ->setViewer($viewer)
  ->withIDs($ids)
  ->withStatuses($releaseable)
  ->execute();
$found = mpull($resources, null, 'getID');
foreach ($ids as $id) {
  if (empty($found[$id])) {
    // flag $id as missing/non-releaseable BEFORE the workflow throws
  }
}

Try / catch

catch (PhutilArgumentUsageException $ex) { if the resource verifiably exists and is releaseable, you are hitting the idx($resources,$id) lookup bug in this revision — use --all or patch the id_map lookup }

Prevention

When it happens

Trigger: Asking for a resource ID that was already released or is in a non-releaseable status; hitting the map-lookup bug when the releaseable result list is not identity-ordered (common when older resources were released, compacting the list); typo'd IDs.

Common situations: Re-running a historical release command whose resources are already gone; draining a partially-drained pool where remaining resources have scattered IDs; any environment where the upstream fix (using `idx($id_map, $id)`) is not applied — the workaround is `--all` or releasing in an order that keeps the list identity-mapped.

Related errors


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