{"record":{"id":"48a56e4e7ead5732","repo":"phacility/phabricator","slug":"no-image-exists-with-phid-s","errorCode":null,"errorMessage":"No image exists with PHID \"%s\".","messagePattern":"No image exists with PHID \"(.+?)\"\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/pholio/editor/PholioMockEditor.php","lineNumber":220,"sourceCode":"\n    switch ($xaction->getTransactionType()) {\n      case PholioMockInlineTransaction::TRANSACTIONTYPE:\n        return true;\n    }\n\n    return parent::shouldImplyCC($object, $xaction);\n  }\n\n  public function loadPholioImage($object, $phid) {\n    if (!isset($this->images[$phid])) {\n\n      $image = id(new PholioImageQuery())\n        ->setViewer($this->getActor())\n        ->withPHIDs(array($phid))\n        ->executeOne();\n\n      if (!$image) {\n        throw new Exception(\n          pht(\n            'No image exists with PHID \"%s\".',\n            $phid));\n      }\n\n      $mock_phid = $image->getMockPHID();\n      if ($mock_phid) {\n        if ($mock_phid !== $object->getPHID()) {\n          throw new Exception(\n            pht(\n              'Image (\"%s\") belongs to the wrong object (\"%s\", expected \"%s\").',\n              $phid,\n              $mock_phid,\n              $object->getPHID()));\n        }\n      }\n\n      $this->images[$phid] = $image;","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/pholio/editor/PholioMockEditor.php#L202-L238","documentation":"PholioMockEditor::loadPholioImage resolves an image PHID with the editor's actor as viewer while applying mock transactions (replace/reorder image). If PholioImageQuery returns nothing for that PHID, the transaction stream references an image that does not exist (or is invisible to the actor), and the edit is aborted with an Exception before anything is written.","triggerScenarios":"A replaceImage/reorder transaction carries a PHID captured before another user deleted that image; concurrent edits where the image was removed between page load and submit; API callers fabricating or replaying PHIDs from a different mock instance.","commonSituations":"Stale browser sessions after a mock was edited by someone else; scripts replaying recorded transaction streams; copy-pasting example PHIDs into custom clients.","solutions":["Reload the mock in the UI and retry the edit against the current image set","For editor/API callers, re-fetch valid image PHIDs with PholioImageQuery scoped to the mock before building transactions","Never reuse PHIDs captured from a different mock or an earlier version of the mock"],"exampleFix":"// before: reusing a stale PHID captured earlier\n$xaction->setNewValue($old_image_phid);\n// after\n$images = id(new PholioImageQuery())\n  ->setViewer($actor)\n  ->withMockPHIDs(array($mock->getPHID()))\n  ->execute();\n$xaction->setNewValue(head($images)->getPHID());","handlingStrategy":"validation","validationCode":"// Verify the image exists (and belongs to this mock) before building transactions\n$image = id(new PholioImageQuery())\n  ->setViewer($actor)\n  ->withPHIDs(array($image_phid))\n  ->withMockPHIDs(array($mock->getPHID()))\n  ->executeOne();\nif (!$image) {\n  throw new Exception('Stale image reference; reload the mock.');\n}","typeGuard":null,"tryCatchPattern":"try {\n  $editor->applyTransactions($mock, $xactions);\n} catch (Exception $ex) {\n  if (strpos($ex->getMessage(), 'No image exists with PHID') !== false) {\n    // stale reference: re-fetch images and rebuild transactions\n  }\n}","preventionTips":["Always re-fetch image PHIDs with PholioImageQuery scoped to the mock at edit time","Discard captured PHIDs when the mock was edited concurrently - reload first","Never replay recorded transaction streams against new mocks"],"tags":["phabricator","pholio","mock","image","stale-reference"],"backgroundTag":"stale-reference","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}