{"record":{"id":"0401d167757184b0","repo":"phacility/phabricator","slug":"failed-to-load-container-object-for-inline-comment","errorCode":null,"errorMessage":"Failed to load container object for inline comment.","messagePattern":"Failed to load container object for inline comment\\.","errorType":"http","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/infrastructure/diff/PhabricatorInlineCommentController.php","lineNumber":19,"sourceCode":"<?php\n\nabstract class PhabricatorInlineCommentController\n  extends PhabricatorController {\n\n  private $containerObject;\n\n  abstract protected function createComment();\n  abstract protected function newInlineCommentQuery();\n  abstract protected function loadCommentForDone($id);\n  abstract protected function loadObjectOwnerPHID(\n    PhabricatorInlineComment $inline);\n  abstract protected function newContainerObject();\n\n  final protected function getContainerObject() {\n    if ($this->containerObject === null) {\n      $object = $this->newContainerObject();\n      if (!$object) {\n        throw new Exception(\n          pht(\n            'Failed to load container object for inline comment.'));\n      }\n      $this->containerObject = $object;\n    }\n\n    return $this->containerObject;\n  }\n\n  protected function hideComments(array $ids) {\n    throw new PhutilMethodNotImplementedException();\n  }\n\n  protected function showComments(array $ids) {\n    throw new PhutilMethodNotImplementedException();\n  }\n\n  private $changesetID;","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/infrastructure/diff/PhabricatorInlineCommentController.php#L1-L37","documentation":"Thrown by PhabricatorInlineCommentController::getContainerObject() when the subclass's newContainerObject() returns null. The container is the object an inline comment lives on (a Differential revision, a Diffusion commit, a mock, etc.); every concrete controller implements newContainerObject() by loading it from the request, typically from an `objectPHID`/revision parameter. A null result means the parameter was missing, malformed, or the object could not be loaded for the acting viewer — the controller treats this as an internal integrity failure (plain Exception, not a usage exception).","triggerScenarios":"An inline comment AJAX request (e.g. `/differential/comment/inline/edit/...` or Diffusion inline endpoints) whose URL/POST omits the object PHID parameter, references a deleted revision/commit, or references an object the viewer cannot see. Also subclass bugs where newContainerObject() forgets a load branch.","commonSituations":"Stale browser tab posting an inline-comment form for a revision that has since been deleted; custom code subclassing PhabricatorInlineCommentController without implementing all load paths; policy changes that hide the container from the commenting user between page render and comment submit.","solutions":["Reload the revision/diff page and re-submit the comment so the request carries fresh, valid container parameters","Verify the container object still exists and is visible to the acting user","If you subclass this controller, ensure newContainerObject() returns a loaded object for every route it serves and audit for null returns"],"exampleFix":"// custom subclass - before\nprotected function newContainerObject() {\n  return id(new PhabricatorRevisionQuery())\n    ->withPHIDs(array($this->objectPHID))\n    ->executeOne();  // may return null -> exception\n}\n\n// after - before calling getContainerObject(), validate the parameter\nprotected function newContainerObject() {\n  $phid = $this->getRequest()->getStr('objectPHID');\n  if (!$phid) {\n    return null;  // reject upstream with a 400 instead of a broken state\n  }\n  return id(new PhabricatorRevisionQuery())\n    ->setViewer($this->getViewer())\n    ->withPHIDs(array($phid))\n    ->executeOne();\n}","handlingStrategy":"validation","validationCode":"// In a controller subclass, validate the container parameter before\n// any inline comment handling\n$request = $this->getRequest();\n$phid = $request->getStr('objectPHID');\nif (!$phid) {\n  return new Aphront400Response();\n}\n$container = id(new PhabricatorObjectQuery())\n  ->setViewer($request->getViewer())\n  ->withPHIDs(array($phid))\n  ->executeOne();\nif (!$container) {\n  return new Aphront404Response();\n}","typeGuard":null,"tryCatchPattern":"// Inside controller code that cannot pre-validate\ntry {\n  $container = $this->getContainerObject();\n} catch (Exception $ex) {\n  return new Aphront404Response(); // container deleted or hidden\n}","preventionTips":["In subclasses, load the container through a policy-aware query with the acting viewer","Return a 400/404 response when the container parameter is missing instead of reaching the throw site","Keep client sessions short on review pages; reload before commenting after the object may have changed"],"tags":["phabricator","inline-comments","code-review","controller","object-load"],"backgroundTag":"record-not-found","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}