phacility/phabricator · error · Exception

Source PHID "%s" does not identify a valid object, or you do

Error message

Source PHID "%s" does not identify a valid object, or you do not have permission to view it.

What it means

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.

Source

Thrown at src/infrastructure/edges/conduit/EdgeSearchConduitAPIMethod.php:88

  }

  protected function execute(ConduitAPIRequest $request) {
    $viewer = $request->getUser();
    $pager = $this->newPager($request);

    $source_phids = $request->getValue('sourcePHIDs', array());
    $edge_types = $request->getValue('types', array());
    $destination_phids = $request->getValue('destinationPHIDs', array());

    $object_query = id(new PhabricatorObjectQuery())
      ->setViewer($viewer)
      ->withNames($source_phids);

    $object_query->execute();
    $objects = $object_query->getNamedResults();
    foreach ($source_phids as $phid) {
      if (empty($objects[$phid])) {
        throw new Exception(
          pht(
            'Source PHID "%s" does not identify a valid object, or you do '.
            'not have permission to view it.',
            $phid));
      }
    }
    $source_phids = mpull($objects, 'getPHID');

    if (!$edge_types) {
      throw new Exception(
        pht(
          'Edge search must specify a nonempty list of edge types.'));
    }

    $edge_map = $this->getConduitEdgeTypeMap();

    $constant_map = array();
    $edge_constants = array();

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Validate each PHID exists via `phid.query`/`phid.lookup` with the same token before calling edge.search
  2. If the object should exist, switch to a token/user whose policies can see it (or adjust the object's policy)
  3. Check the PHID type prefix is well-formed (e.g. `PHID-PROJ-`, `PHID-TASK-`) against the object you intend

Example fix

// before
$result = $client->callMethod('edge.search', array(
  'sourcePHIDs' => array($maybe_stale_phid),
  'types' => array('task.project'),
));

// after - resolve sources first
$lookup = $client->callMethod('phid.query', array(
  'phids' => array($maybe_stale_phid),
));
if (empty($lookup[$maybe_stale_phid])) {
  throw new RuntimeException('Source PHID unresolvable: '.$maybe_stale_phid);
}
$result = $client->callMethod('edge.search', array(
  'sourcePHIDs' => array($maybe_stale_phid),
  'types' => array('task.project'),
));
Defensive patterns

Strategy: validation

Validate before calling

// Resolve every source PHID with the same access context first
$lookup = $client->callMethod('phid.query', array(
  'phids' => $source_phids,
));
$valid = array();
foreach ($source_phids as $phid) {
  if (isset($lookup[$phid])) {
    $valid[] = $phid;
  }
}
if (!$valid) {
  throw new RuntimeException('No resolvable source PHIDs for edge.search');
}
$result = $client->callMethod('edge.search', array(
  'sourcePHIDs' => $valid,
  'types' => $types,
));

Type guard

function isPhid($value) {
  return is_string($value)
    && (bool) preg_match('/^PHID-[A-Z]{4}-[a-z0-9]{8,}$/', $value);
}

Try / catch

try {
  $result = $client->callMethod('edge.search', $params);
} catch (ConduitClientException $ex) {
  if (strpos($ex->getMessage(), 'does not identify a valid object') !== false) {
    // filter/repair sourcePHIDs and retry once
  }
  throw $ex;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/72f5570a2d4e85a6. Report an issue: GitHub.