phacility/phabricator · error · Exception

File is not viewable.

Error message

File is not viewable.

What it means

While rendering an inline Pholio comment in view mode, the controller loads the mock image's underlying Phabricator file and requires isViewableImage() - a MIME type browsers can display (png, jpeg, gif, svg, etc.). If the file record exists but its MIME type is not viewable image data, rendering aborts with a plain Exception 'File is not viewable.'. Usually the stored MIME is wrong (generic application/octet-stream) or the blob was replaced with non-image data.

Source

Thrown at src/applications/pholio/controller/PholioInlineController.php:67

    $v_content = $inline->getContent();

    // TODO: Not correct, but we don't always have a mock right now.
    $mock_uri = '/';

    if ($mode == 'view') {
      require_celerity_resource('pholio-inline-comments-css');
      $image = id(new PholioImageQuery())
        ->setViewer($viewer)
        ->withIDs(array($inline->getImageID()))
        ->executeOne();

      $handles = $this->loadViewerHandles(array($inline->getAuthorPHID()));
      $author_handle = $handles[$inline->getAuthorPHID()];

      $file = $image->getFile();
      if (!$file->isViewableImage()) {
        throw new Exception(pht('File is not viewable.'));
      }

      $image_uri = $file->getBestURI();

      $thumb = id(new PHUIImageMaskView())
        ->addClass('mrl')
        ->setImage($image_uri)
        ->setDisplayHeight(200)
        ->setDisplayWidth(498)
        ->withMask(true)
        ->centerViewOnPoint(
          $inline->getX(), $inline->getY(),
          $inline->getHeight(), $inline->getWidth());

      $comment_head = phutil_tag(
        'div',
        array(
          'class' => 'pholio-inline-comment-head',

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Re-upload the image to the mock so a fresh file with a correct MIME type is created
  2. Look up the file by PHID in the Files application and inspect its MIME type and data
  3. If you migrated data, fix the file records to carry real MIME types (image/png, image/jpeg, ...)
Defensive patterns

Strategy: validation

Validate before calling

// Check the file is actually a viewable image before rendering
$file = $image->getFile();
if (!$file || !$file->isViewableImage()) {
  return $this->newDialog()->setTitle(pht('Unavailable Image'));
}

Type guard

function isViewableImageFile(PhabricatorFile $file) {
  return (bool)$file->isViewableImage();
}

Prevention

When it happens

Trigger: Opening an inline comment on a mock whose image file record carries a non-image MIME type; files imported/migrated without correct MIME metadata; uploads where the extension lied about content (a PDF renamed to .png).

Common situations: Data imports from other review tools that stored blobs without MIME; storage migrations losing metadata; corrupt or truncated uploads.

Related errors


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