{"record":{"id":"9cec1c676a6abf87","repo":"phacility/phabricator","slug":"lease-s-could-not-be-loaded","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/drydock/worker/DrydockRepositoryOperationUpdateWorker.php","lineNumber":102,"sourceCode":"\n  private function loadWorkingCopyLease(\n    DrydockRepositoryOperation $operation) {\n    $viewer = $this->getViewer();\n\n    // TODO: This is very similar to leasing in Harbormaster, maybe we can\n    // share some of the logic?\n\n    $working_copy = new DrydockWorkingCopyBlueprintImplementation();\n    $working_copy_type = $working_copy->getType();\n\n    $lease_phid = $operation->getProperty('exec.leasePHID');\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      $repository = $operation->getRepository();\n\n      $allowed_phids = $repository->getAutomationBlueprintPHIDs();\n      $authorizing_phid = $repository->getPHID();\n\n      $lease = DrydockLease::initializeNewLease()\n        ->setResourceType($working_copy_type)\n        ->setOwnerPHID($operation->getPHID())\n        ->setAuthorizingPHID($authorizing_phid)\n        ->setAllowedBlueprintPHIDs($allowed_phids);\n\n      $map = $this->buildRepositoryMap($operation);\n","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/worker/DrydockRepositoryOperationUpdateWorker.php#L84-L120","documentation":"DrydockRepositoryOperationUpdateWorker remembers the working-copy lease PHID in the operation property 'exec.leasePHID'. On later runs it loads that lease; if the query (with the daemons' omnipotent viewer) cannot find it, the operation fails permanently. The lease was deleted or is in a state where it no longer exists, so the operation can never continue.","triggerScenarios":"The operation's lease was destroyed between worker runs (lease expiry, reclamation, manual destroy); the property points at a PHID from another install (database restore or copy); the lease row was removed directly.","commonSituations":"Long-running repository operations (merge, land) whose lease is garbage-collected; restoring a Phabricator database without the matching Drydock rows; aggressive lease reclamation settings.","solutions":["Verify the lease PHID still exists: query DrydockLease by PHID or check the Drydock lease UI.","If the lease is gone, re-run or restart the repository operation so it allocates a fresh lease.","Prevent premature lease destruction: keep the operation worker running and avoid reclaiming leases that belong to active operations."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"$lease = id(new DrydockLeaseQuery())\n  ->setViewer(PhabricatorUser::getOmnipotentUser())\n  ->withPHIDs(array($operation->getProperty('exec.leasePHID')))\n  ->executeOne();\nif (!$lease) {\n  // clear the stale property and let the operation allocate a fresh lease\n  $operation->setProperty('exec.leasePHID', null)->save();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not destroy leases that back an in-flight repository operation.","Treat a missing exec.leasePHID lease as recoverable: reset the property and re-lease rather than failing the operation."],"tags":["drydock","php","repository-operations","lease","missing-object","permanent-failure"],"backgroundTag":"missing-related-object","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}