{"record":{"id":"88c384e5c7e86c57","repo":"phacility/phabricator","slug":"lease-s-could-not-be-loaded-88c384","errorCode":null,"errorMessage":"Lease \"%s\" could not be loaded.","messagePattern":"Lease \"(.+?)\" could not be loaded\\.","errorType":"exception","errorClass":"PhabricatorWorkerPermanentFailureException","httpStatus":null,"severity":"error","filePath":"src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php","lineNumber":35,"sourceCode":"\n  public function execute(\n    HarbormasterBuild $build,\n    HarbormasterBuildTarget $build_target) {\n    $viewer = PhabricatorUser::getOmnipotentUser();\n\n    $settings = $this->getSettings();\n\n    // TODO: We should probably have a separate temporary storage area for\n    // execution stuff that doesn't step on configuration state?\n    $lease_phid = $build_target->getDetail('exec.leasePHID');\n\n    if ($lease_phid) {\n      $lease = id(new DrydockLeaseQuery())\n        ->setViewer($viewer)\n        ->withPHIDs(array($lease_phid))\n        ->executeOne();\n      if (!$lease) {\n        throw new PhabricatorWorkerPermanentFailureException(\n          pht(\n            'Lease \"%s\" could not be loaded.',\n            $lease_phid));\n      }\n    } else {\n      $working_copy_type = id(new DrydockWorkingCopyBlueprintImplementation())\n        ->getType();\n\n      $allowed_phids = $build_target->getFieldValue('blueprintPHIDs');\n      if (!is_array($allowed_phids)) {\n        $allowed_phids = array();\n      }\n      $authorizing_phid = $build_target->getBuildStep()->getPHID();\n\n      $lease = DrydockLease::initializeNewLease()\n        ->setResourceType($working_copy_type)\n        ->setOwnerPHID($build_target->getPHID())\n        ->setAuthorizingPHID($authorizing_phid)","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/harbormaster/step/HarbormasterLeaseWorkingCopyBuildStepImplementation.php#L17-L53","documentation":"The 'Lease Working Copy' step stores the acquired Drydock lease PHID in the target detail 'exec.leasePHID'. When the target runs again, it re-loads the lease by PHID; if the lease no longer exists (destroyed, released, or garbage-collected) this PhabricatorWorkerPermanentFailureException is thrown, permanently failing the worker task and the build target.","triggerScenarios":"A build target yielded or retried after saving 'exec.leasePHID' (e.g. lease still activating), and in the meantime the lease was released or expired and was destroyed by Drydock. Also triggered by manually releasing Drydock leases while builds are pending.","commonSituations":"Long-running builds outliving lease lifetime; aggressive Drydock resource reclaim settings; an administrator releasing leases from the Drydock console during a build; daemons backed up so retries happen much later.","solutions":["Restart the build (or re-run the target) so the step acquires a fresh working-copy lease instead of reusing the dead PHID.","Check the Drydock lease and resource logs for why the lease was destroyed (expired, reclaimed, blueprint failure).","Increase lease/resource lifetime or reduce reclaim aggressiveness so leases survive worker retry delays.","Avoid manually releasing Drydock leases while Harbormaster builds are in progress."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Before re-running a target that already has a lease detail:\n$lease_phid = $build_target->getDetail('exec.leasePHID');\nif ($lease_phid) {\n  $lease = id(new DrydockLeaseQuery())\n    ->setViewer(PhabricatorUser::getOmnipotentUser())\n    ->withPHIDs(array($lease_phid))\n    ->executeOne();\n  if (!$lease) {\n    // lease is gone - restart the build to acquire a fresh one\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  // execute lease step\n} catch (PhabricatorWorkerPermanentFailureException $ex) {\n  if (preg_match('/could not be loaded/', $ex->getMessage())) {\n    // permanent: do not retry the same target; restart the build\n  }\n}","preventionTips":["Do not manually release Drydock leases while builds are pending.","Keep lease lifetimes comfortably longer than worst-case worker retry delays.","Monitor Drydock lease garbage collection when build queues are backed up."],"tags":["harbormaster","drydock","lease","phabricator"],"backgroundTag":"dangling-foreign-key-reference","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}