phacility/phabricator · error · Exception

File size disagrees with uploaded size.

Error message

File size disagrees with uploaded size.

What it means

Post-upload consistency check: the byte size declared in the upload spec ('size') disagrees with the size of the temporary file actually written, meaning the transfer was truncated or the metadata is inconsistent.

Solutions

  1. Retry the upload; size mismatches usually stem from interrupted transfers
  2. Check for proxies or middleware that alter request bodies
  3. Verify client-side hashing/length computation matches actual bytes sent
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/applications/files/storage/PhabricatorFile.php:215 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/a21e2b6afba7606a. Report an issue: GitHub.

Appendix: source

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

    $tmp_name = idx($spec, 'tmp_name');

    // NOTE: If we parsed the request body ourselves, the files we wrote will
    // not be registered in the `is_uploaded_file()` list. It's fine to skip
    // this check: it just protects against sloppy code from the long ago era
    // of "register_globals".

    if (ini_get('enable_post_data_reading')) {
      $is_valid = @is_uploaded_file($tmp_name);
      if (!$is_valid) {
        throw new Exception(pht('File is not an uploaded file.'));
      }
    }

    $file_data = Filesystem::readFile($tmp_name);
    $file_size = idx($spec, 'size');

    if (strlen($file_data) != $file_size) {
      throw new Exception(pht('File size disagrees with uploaded size.'));
    }

    return $file_data;
  }

  public static function newFromPHPUpload($spec, array $params = array()) {
    $file_data = self::readUploadedFileData($spec);

    $file_name = nonempty(
      idx($params, 'name'),
      idx($spec,   'name'));
    $params = array(
      'name' => $file_name,
    ) + $params;

    return self::newFromFileData($file_data, $params);
  }

View on GitHub (pinned to 5720a38cfe)