phacility/phabricator · error · Exception

Failed to load container object for inline comment.

Error message

Failed to load container object for inline comment.

What it means

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

Source

Thrown at src/infrastructure/diff/PhabricatorInlineCommentController.php:19

<?php

abstract class PhabricatorInlineCommentController
  extends PhabricatorController {

  private $containerObject;

  abstract protected function createComment();
  abstract protected function newInlineCommentQuery();
  abstract protected function loadCommentForDone($id);
  abstract protected function loadObjectOwnerPHID(
    PhabricatorInlineComment $inline);
  abstract protected function newContainerObject();

  final protected function getContainerObject() {
    if ($this->containerObject === null) {
      $object = $this->newContainerObject();
      if (!$object) {
        throw new Exception(
          pht(
            'Failed to load container object for inline comment.'));
      }
      $this->containerObject = $object;
    }

    return $this->containerObject;
  }

  protected function hideComments(array $ids) {
    throw new PhutilMethodNotImplementedException();
  }

  protected function showComments(array $ids) {
    throw new PhutilMethodNotImplementedException();
  }

  private $changesetID;

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Reload the revision/diff page and re-submit the comment so the request carries fresh, valid container parameters
  2. Verify the container object still exists and is visible to the acting user
  3. If you subclass this controller, ensure newContainerObject() returns a loaded object for every route it serves and audit for null returns

Example fix

// custom subclass - before
protected function newContainerObject() {
  return id(new PhabricatorRevisionQuery())
    ->withPHIDs(array($this->objectPHID))
    ->executeOne();  // may return null -> exception
}

// after - before calling getContainerObject(), validate the parameter
protected function newContainerObject() {
  $phid = $this->getRequest()->getStr('objectPHID');
  if (!$phid) {
    return null;  // reject upstream with a 400 instead of a broken state
  }
  return id(new PhabricatorRevisionQuery())
    ->setViewer($this->getViewer())
    ->withPHIDs(array($phid))
    ->executeOne();
}
Defensive patterns

Strategy: validation

Validate before calling

// In a controller subclass, validate the container parameter before
// any inline comment handling
$request = $this->getRequest();
$phid = $request->getStr('objectPHID');
if (!$phid) {
  return new Aphront400Response();
}
$container = id(new PhabricatorObjectQuery())
  ->setViewer($request->getViewer())
  ->withPHIDs(array($phid))
  ->executeOne();
if (!$container) {
  return new Aphront404Response();
}

Try / catch

// Inside controller code that cannot pre-validate
try {
  $container = $this->getContainerObject();
} catch (Exception $ex) {
  return new Aphront404Response(); // container deleted or hidden
}

Prevention

When it happens

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

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

Related errors


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