{"record":{"id":"0895b320053729a4","repo":"phacility/phabricator","slug":"working-copy-lease-is-missing-required-attribute","errorCode":null,"errorMessage":"Working copy lease is missing required attribute \"%s\".\n\nAttribute \"repositories.map\" should be a map of repository specifications.","messagePattern":"Working copy lease is missing required attribute \"(.+?)\"\\.\n\nAttribute \"repositories\\.map\" should be a map of repository specifications\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php","lineNumber":172,"sourceCode":"    if (!is_array($map) || !$map) {\n      $message = array();\n      if ($map === null) {\n        $message[] = pht(\n          'Working copy lease is missing required attribute \"%s\".',\n          $attribute);\n      } else {\n        $message[] = pht(\n          'Working copy lease has invalid attribute \"%s\".',\n          $attribute);\n      }\n\n      $message[] = pht(\n        'Attribute \"repositories.map\" should be a map of repository '.\n        'specifications.');\n\n      $message = implode(\"\\n\\n\", $message);\n\n      throw new Exception($message);\n    }\n\n    foreach ($map as $key => $value) {\n      $map[$key] = array_select_keys(\n        $value,\n        array(\n          'phid',\n        ));\n    }\n\n    return $map;\n  }\n\n  public function activateResource(\n    DrydockBlueprint $blueprint,\n    DrydockResource $resource) {\n\n    $lease = $this->loadHostLease($resource);","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/drydock/blueprint/DrydockWorkingCopyBlueprintImplementation.php#L154-L190","documentation":"The working-copy blueprint expects leases to carry a `repositories.map` attribute describing which repositories to check out; it validates the attribute when building the map. If the attribute is missing entirely, the first message line reported is that the lease is missing the required attribute, followed by an explanation of the expected shape (a map of repository specifications). Callers of Drydock requesting working-copy leases must set this attribute before activation.","triggerScenarios":"Creating/queueing a Drydock working-copy lease without calling setAttribute('repositories.map', ...) — or setting it to a non-array — and letting the working-copy blueprint process it. The thrown Exception embeds both the missing-attribute notice and the expected format.","commonSituations":"Harbormaster/build integrations or custom lease-request scripts that construct the lease manually and forget the attribute; copy-paste lease code from a different blueprint type (host leases need no repositories.map); attribute key typo like 'repositories.map ' or 'repository.map'.","solutions":["Set the attribute on the lease before queueing: setAttribute('repositories.map', array(...)) with one entry per repository","Each map entry needs at least a 'phid' key naming the repository PHID to clone","Acquire the lease only after all required attributes are set, and log attributes before queueing in custom code"],"exampleFix":"// before\n$lease = id(new DrydockLease())\n  ->setResourceType('working-copy')\n  ->queueForActivate();\n// after\n$lease = id(new DrydockLease())\n  ->setResourceType('working-copy')\n  ->setAttribute(\n    'repositories.map',\n    array(\n      array('phid' => 'PHID-REPO-xxxxxxxxxxxxxxxxxxxx'),\n    ))\n  ->queueForActivate();","handlingStrategy":"validation","validationCode":"$map = $lease->getAttribute('repositories.map');\nif (!is_array($map) || !$map) {\n  // Set the attribute before queueing the lease for activation.\n  $lease->setAttribute(\n    'repositories.map',\n    array(\n      array('phid' => $repository_phid),\n    ));\n}","typeGuard":"function is_valid_repositories_map($value) {\n  if (!is_array($value) || !$value) {\n    return false;\n  }\n  foreach ($value as $spec) {\n    if (!is_array($spec) || empty($spec['phid'])) {\n      return false;\n    }\n  }\n  return true;\n}","tryCatchPattern":null,"preventionTips":["Always set 'repositories.map' (a map of specs with 'phid' keys) on working-copy leases","Set all attributes before queueForActivate(); attributes are consumed during allocation","Log lease attributes in custom lease-request code to catch typos like 'repository.map'"],"tags":["phabricator","drydock","lease","attributes","working-copy"],"backgroundTag":"missing-required-attribute","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}