{"record":{"id":"86bbb5288ac57e33","repo":"phacility/phabricator","slug":"resource-s-does-not-exist","errorCode":null,"errorMessage":"Resource \"%s\" does not exist.","messagePattern":"Resource \"(.+?)\" does not exist\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/drydock/management/DrydockManagementReleaseResourceWorkflow.php","lineNumber":55,"sourceCode":"\n    $query = id(new DrydockResourceQuery())\n      ->setViewer($viewer)\n      ->withStatuses(mpull($statuses, 'getKey'));\n\n    if ($ids) {\n      $query->withIDs($ids);\n    }\n\n    $resources = $query->execute();\n\n    if ($ids) {\n      $id_map = mpull($resources, null, 'getID');\n\n      foreach ($ids as $id) {\n        $resource = idx($resources, $id);\n\n        if (!$resource) {\n          throw new PhutilArgumentUsageException(\n            pht('Resource \"%s\" does not exist.', $id));\n        }\n      }\n\n      $resources = array_select_keys($id_map, $ids);\n    }\n\n    if (!$resources) {\n      echo tsprintf(\n        \"%s\\n\",\n        pht('No resources selected for release.'));\n\n      return 0;\n    }\n\n    $drydock_phid = id(new PhabricatorDrydockApplication())->getPHID();\n\n    PhabricatorWorker::setRunAllTasksInProcess(true);","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/management/DrydockManagementReleaseResourceWorkflow.php#L37-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the resource really exists and is releaseable: check the Drydock resource UI or run the resource query, then re-run with correct IDs","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","If it was already released, no action is needed","Upgrade the Phabricator checkout; later revisions fix the id_map lookup"],"exampleFix":"// before (DrydockManagementReleaseResourceWorkflow.php)\n$resource = idx($resources, $id);\nif (!$resource) {\n  throw new PhutilArgumentUsageException(\n    pht('Resource \"%s\" does not exist.', $id));\n}\n\n// after\n$resource = idx($id_map, $id);\nif (!$resource) {\n  throw new PhutilArgumentUsageException(\n    pht('Resource \"%s\" does not exist.', $id));\n}","handlingStrategy":"validation","validationCode":"// Verify IDs against releaseable resources before running:\n$releaseable = array();\nforeach (DrydockResourceStatus::getAllStatuses() as $key => $status) {\n  if (DrydockResourceStatus::newStatusObject($status)->canRelease()) {\n    $releaseable[] = $key;\n  }\n}\n$resources = id(new DrydockResourceQuery())\n  ->setViewer($viewer)\n  ->withIDs($ids)\n  ->withStatuses($releaseable)\n  ->execute();\n$found = mpull($resources, null, 'getID');\nforeach ($ids as $id) {\n  if (empty($found[$id])) {\n    // flag $id as missing/non-releaseable BEFORE the workflow throws\n  }\n}","typeGuard":null,"tryCatchPattern":"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 }","preventionTips":["Validate IDs against a keyed map (getID => object), not the raw result list","Note this revision's latent bug: idx($resources, $id) should be idx($id_map, $id); false 'does not exist' on valid IDs is expected until patched","Remember non-releaseable statuses (e.g. already released) are invisible to the workflow"],"tags":["drydock","phabricator","cli","not-found","resource","status-filter","lookup-bug"],"backgroundTag":"entity-not-found-by-id","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}