{"record":{"id":"72f5570a2d4e85a6","repo":"phacility/phabricator","slug":"source-phid-s-does-not-identify-a-valid-object","errorCode":null,"errorMessage":"Source PHID \"%s\" does not identify a valid object, or you do not have permission to view it.","messagePattern":"Source PHID \"(.+?)\" does not identify a valid object, or you do not have permission to view it\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/infrastructure/edges/conduit/EdgeSearchConduitAPIMethod.php","lineNumber":88,"sourceCode":"  }\n\n  protected function execute(ConduitAPIRequest $request) {\n    $viewer = $request->getUser();\n    $pager = $this->newPager($request);\n\n    $source_phids = $request->getValue('sourcePHIDs', array());\n    $edge_types = $request->getValue('types', array());\n    $destination_phids = $request->getValue('destinationPHIDs', array());\n\n    $object_query = id(new PhabricatorObjectQuery())\n      ->setViewer($viewer)\n      ->withNames($source_phids);\n\n    $object_query->execute();\n    $objects = $object_query->getNamedResults();\n    foreach ($source_phids as $phid) {\n      if (empty($objects[$phid])) {\n        throw new Exception(\n          pht(\n            'Source PHID \"%s\" does not identify a valid object, or you do '.\n            'not have permission to view it.',\n            $phid));\n      }\n    }\n    $source_phids = mpull($objects, 'getPHID');\n\n    if (!$edge_types) {\n      throw new Exception(\n        pht(\n          'Edge search must specify a nonempty list of edge types.'));\n    }\n\n    $edge_map = $this->getConduitEdgeTypeMap();\n\n    $constant_map = array();\n    $edge_constants = array();","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/edges/conduit/EdgeSearchConduitAPIMethod.php#L70-L106","documentation":"Thrown by the `edge.search` Conduit method when a PHID in `sourcePHIDs` cannot be resolved by PhabricatorObjectQuery for the acting user. Resolution is policy-filtered, so the error conflates two causes named in the message: the PHID is not a valid/existing object, or it exists but the API user cannot see it. Every source PHID must resolve before the edge query runs.","triggerScenarios":"Calling `edge.search` via Conduit with a malformed PHID (`PHID-XXXX-...`), a PHID from another install, a deleted object's PHID, or a valid PHID hidden by policy from the API token's user (e.g. a confidential project's member PHID queried by a basic token).","commonSituations":"Scripts piping PHIDs harvested from old records into a refreshed install; API tokens belonging to restricted users; multi-tenant or staged environments where object visibility differs per environment; typos when PHIDs are assembled by string concatenation.","solutions":["Validate each PHID exists via `phid.query`/`phid.lookup` with the same token before calling edge.search","If the object should exist, switch to a token/user whose policies can see it (or adjust the object's policy)","Check the PHID type prefix is well-formed (e.g. `PHID-PROJ-`, `PHID-TASK-`) against the object you intend"],"exampleFix":"// before\n$result = $client->callMethod('edge.search', array(\n  'sourcePHIDs' => array($maybe_stale_phid),\n  'types' => array('task.project'),\n));\n\n// after - resolve sources first\n$lookup = $client->callMethod('phid.query', array(\n  'phids' => array($maybe_stale_phid),\n));\nif (empty($lookup[$maybe_stale_phid])) {\n  throw new RuntimeException('Source PHID unresolvable: '.$maybe_stale_phid);\n}\n$result = $client->callMethod('edge.search', array(\n  'sourcePHIDs' => array($maybe_stale_phid),\n  'types' => array('task.project'),\n));","handlingStrategy":"validation","validationCode":"// Resolve every source PHID with the same access context first\n$lookup = $client->callMethod('phid.query', array(\n  'phids' => $source_phids,\n));\n$valid = array();\nforeach ($source_phids as $phid) {\n  if (isset($lookup[$phid])) {\n    $valid[] = $phid;\n  }\n}\nif (!$valid) {\n  throw new RuntimeException('No resolvable source PHIDs for edge.search');\n}\n$result = $client->callMethod('edge.search', array(\n  'sourcePHIDs' => $valid,\n  'types' => $types,\n));","typeGuard":"function isPhid($value) {\n  return is_string($value)\n    && (bool) preg_match('/^PHID-[A-Z]{4}-[a-z0-9]{8,}$/', $value);\n}","tryCatchPattern":"try {\n  $result = $client->callMethod('edge.search', $params);\n} catch (ConduitClientException $ex) {\n  if (strpos($ex->getMessage(), 'does not identify a valid object') !== false) {\n    // filter/repair sourcePHIDs and retry once\n  }\n  throw $ex;\n}","preventionTips":["Validate PHID syntax client-side before any conduit call","Use an API token whose owner can see every object you query; prefer a bot account with explicit memberships","Resolve PHIDs close to the call, not from long-lived caches, in installs where objects get deleted"],"tags":["phabricator","conduit","api","edges","not-found","policy","phid"],"backgroundTag":"record-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}