phacility/phabricator · error · Exception

Refusing to assess image dimensions of file chunk.

Error message

Refusing to assess image dimensions of file chunk.

What it means

Fires in updateDimensions when the file record itself is a chunk (a piece of a chunked large-file upload). Dimension metadata belongs to the fully reassembled file, so the method refuses to load chunk data into the image parser to avoid decoding a partial byte stream.

Solutions

  1. Operate on the parent file that the chunks compose into, not a chunk record
  2. Skip dimension updates for objects where getIsChunk() is true
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/applications/files/storage/PhabricatorFile.php:1106 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/applications/files/storage/PhabricatorFile.php:1106

    foreach ($iterator as $chunk) {
      $result .= $chunk;
    }

    return $result;
  }

  public function updateDimensions($save = true) {
    if (!$this->isViewableImage()) {
      throw new Exception(pht('This file is not a viewable image.'));
    }

    if (!function_exists('imagecreatefromstring')) {
      throw new Exception(pht('Cannot retrieve image information.'));
    }

    if ($this->getIsChunk()) {
      throw new Exception(
        pht('Refusing to assess image dimensions of file chunk.'));
    }

    $engine = $this->instantiateStorageEngine();
    if ($engine->isChunkEngine()) {
      throw new Exception(
        pht('Refusing to assess image dimensions of chunked file.'));
    }

    $data = $this->loadFileData();

    $img = @imagecreatefromstring($data);
    if ($img === false) {
      throw new Exception(pht('Error when decoding image.'));
    }

    $this->metadata[self::METADATA_IMAGE_WIDTH] = imagesx($img);
    $this->metadata[self::METADATA_IMAGE_HEIGHT] = imagesy($img);

View on GitHub (pinned to 5720a38cfe)