{"record":{"id":"f60e44fc785f1490","repo":"phacility/phabricator","slug":"err-bad-phid-f60e44","errorCode":"ERR-BAD-PHID","errorMessage":"ERR-BAD-PHID","messagePattern":"ERR-BAD-PHID","errorType":"error_code","errorClass":"ConduitException","httpStatus":null,"severity":"error","filePath":"src/applications/phid/conduit/PHIDInfoConduitAPIMethod.php","lineNumber":46,"sourceCode":"    return 'nonempty dict<string, wild>';\n  }\n\n  protected function defineErrorTypes() {\n    return array(\n      'ERR-BAD-PHID' => pht('No such object exists.'),\n    );\n  }\n\n  protected function execute(ConduitAPIRequest $request) {\n    $phid = $request->getValue('phid');\n\n    $handle = id(new PhabricatorHandleQuery())\n      ->setViewer($request->getUser())\n      ->withPHIDs(array($phid))\n      ->executeOne();\n\n    if (!$handle->isComplete()) {\n      throw new ConduitException('ERR-BAD-PHID');\n    }\n\n    return $this->buildHandleInformationDictionary($handle);\n  }\n\n}\n","sourceCodeStart":28,"sourceCodeEnd":53,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/phid/conduit/PHIDInfoConduitAPIMethod.php#L28-L53","documentation":"Conduit method phid.query (PHIDInfoConduitAPIMethod) resolves the supplied phid through PhabricatorHandleQuery with the API user as viewer. If the resulting handle is not complete - the PHID is malformed, refers to a deleted object, or to an object the acting user cannot see - the method raises ConduitException with error code ERR-BAD-PHID. It signals an unresolvable identifier rather than a transport failure.","triggerScenarios":"Calling phid.query with a typo'd or truncated PHID; passing a monogram like T123 where a PHID (PHID-TASK-...) is required; referencing a deleted object's PHID from stale exports; the API token's owner lacking policy visibility on the object.","commonSituations":"Integrations piping old PHIDs from previous exports; string concatenation bugs mangling identifiers; permission mismatch between the Conduit token owner and the object's view policy.","solutions":["Validate the PHID shape first (matches /^PHID-[A-Z]{2,4}-/ before calling)","Resolve monograms with phid.lookup ('T123', 'D45') to obtain real PHIDs","If deleted or policy-hidden objects are expected, catch the ConduitException and skip entries with code ERR-BAD-PHID"],"exampleFix":"// before\n$info = $conduit->executeMethod('phid.query', array('phid' => $phid)); // raw call\n// after\nif (!preg_match('/^PHID-[A-Z]{2,4}-/', $phid)) {\n  continue; // not a PHID; resolve via phid.lookup instead\n}\ntry {\n  $info = $conduit->executeMethod('phid.query', array('phid' => $phid));\n} catch (ConduitClientException $ex) {\n  if ($ex->getErrorCode() === 'ERR-BAD-PHID') { continue; }\n  throw $ex;\n}","handlingStrategy":"try-catch","validationCode":"if (!preg_match('/^PHID-[A-Z]{2,4}-[a-z0-9]+$/', $phid)) {\n  // not a well-formed PHID; resolve monograms via phid.lookup first\n  return null;\n}","typeGuard":"function isLikelyPhid($value) {\n  return is_string($value) && preg_match('/^PHID-[A-Z]{2,4}-/', $value) === 1;\n}","tryCatchPattern":"try {\n  $info = $conduit->executeMethod('phid.query', array('phid' => $phid));\n} catch (ConduitClientException $ex) {\n  if ($ex->getErrorCode() === 'ERR-BAD-PHID') {\n    // unknown, deleted, or policy-hidden object: skip it\n    continue;\n  }\n  throw $ex;\n}","preventionTips":["Validate PHID shape before calling phid.query","Resolve monograms (T123/D45) with phid.lookup to get real PHIDs","Treat ERR-BAD-PHID as an expected, skippable condition when processing stale exports"],"tags":["phabricator","conduit","api","phid","invalid-identifier"],"backgroundTag":"invalid-identifier","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}