commaai/openpilot · critical · Exception

Uncompressed size mismatch

Error message

Uncompressed size mismatch

What it means

After writing, out.tell() must equal partition['size']. A size mismatch means the unsparsified output was shorter or longer than the manifest declares — typically truncation from a dropped connection that wasn't caught by the hash checks failing first, or a sparse image whose total block count disagrees with the manifest.

Source

Thrown at openpilot/common/hardware/comma/agnos.py:182

    last_p = 0
    raw_hash = hashlib.sha256()
    f = unsparsify if partition['sparse'] else noop
    for chunk in f(downloader):
      raw_hash.update(chunk)
      out.write(chunk)
      p = int(out.tell() / partition['size'] * 100)
      if p != last_p:
        last_p = p
        print(f"Installing {partition['name']}: {p}", flush=True)

    if raw_hash.hexdigest().lower() != partition['hash_raw'].lower():
      raise Exception(f"Raw hash mismatch '{raw_hash.hexdigest().lower()}'")

    if downloader.sha256.hexdigest().lower() != partition['hash'].lower():
      raise Exception("Uncompressed hash mismatch")

    if out.tell() != partition['size']:
      raise Exception("Uncompressed size mismatch")

    os.sync()


def flash_partition(target_slot_number: int, partition: dict, cloudlog, standalone=False):
  cloudlog.info(f"Downloading and writing {partition['name']}")

  if verify_partition(target_slot_number, partition):
    cloudlog.info(f"Already flashed {partition['name']}")
    return

  # Clear hash before flashing in case we get interrupted
  full_check = partition['full_check']
  if not full_check:
    clear_partition_hash(target_slot_number, partition)

  path = get_partition_path(target_slot_number, partition)

View on GitHub (pinned to 516ec1e682)

Solutions

  1. Retry the full flash from scratch
  2. Confirm the manifest and partition images are the same release
  3. Check target device disk health / available space on the partition
Defensive patterns

Strategy: retry

Validate before calling

if os.path.getsize(image_path) != partition['size']:
    redownload(partition)

Try / catch

try:
    flash_partition(slot, partition, cloudlog)
except Exception as e:
    if "size mismatch" in str(e):
        full_redownload_and_retry()

Prevention

When it happens

Trigger: flash_partition where the total bytes written differ from partition['size'] — truncated download stream that ended cleanly, or manifest/image version skew.

Common situations: Server closed the connection early with a valid-looking end of stream; mismatched manifest entries; disk/partition target smaller than expected causing short writes.

Related errors


AI-assisted analysis of commaai/openpilot@516ec1e682 (2026-08-15). Data as JSON: /api/errors/a791ea43a95714b5. Report an issue: GitHub.