Skip to content

LZ4 decompession failed #353

Open
Open

Description

@smpial

Code

import os
import UnityPy


UnityPy.config.FALLBACK_UNITY_VERSION = '2022.3.52f1'

env = UnityPy.load('avgbg_assets_bg0001_q_15caadfac7a047db4ea676ea62806d56.bundle')
for obj in env.objects:
    print(obj.type.name)
print('End')

Error

C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\files\BundleFile.py:526: UnityVersionFallbackWarning: No valid Unity version found, defaulting to UnityPy.config.FALLBACK_UNITY_VERSION (2022.3.52f1)
  version_str = config.get_fallback_version()
Traceback (most recent call last):
  File "E:\code\unity_unpack\test.py", line 7, in <module>
    env = UnityPy.load('avgbg_assets_bg0001_q_15caadfac7a047db4ea676ea62806d56.bundle')
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\environment.py", line 63, in __init__
    self.load_file(arg)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\environment.py", line 152, in load_file
    f = parse_file(reader, self, name=stream_name, typ=typ, is_dependency=is_dependency)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\helpers\ImportHelper.py", line 141, in parse_file
    f = files.BundleFile(reader, parent, name=name, is_dependency=is_dependency)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\files\BundleFile.py", line 46, in __init__
    m_DirectoryInfo, blocksReader = self.read_fs(reader)
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\files\BundleFile.py", line 174, in read_fs
    b"".join(
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\files\BundleFile.py", line 175, in <genexpr>
    self.decompress_data(
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\files\BundleFile.py", line 511, in decompress_data
    CompressionHelper.DECOMPRESSION_MAP[comp_flag](compressed_data, uncompressed_size),
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\UnityPy\helpers\CompressionHelper.py", line 94, in decompress_lz4
    return lz4.block.decompress(data, uncompressed_size)
_block.LZ4BlockError: Decompression failed: corrupt input or insufficient space in destination buffer. Error code: 33627

Bug
Lib should load file, but raises an exception

To Reproduce

Activity

  1. isHarryh commented on Dec 17, 2025

    @isHarryh
    Contributor

    Maybe the bundle file is not complete. It seems like some bytes are missing in the end of file.

    The decompression error occurred at the last LZ4HC block of the file. The following image shows why and where the decompression error occurred.

    Image

    Left: LZ4 block decompression code implemented in Python; Right: Your file.

    Reads more about LZ4 block: https://github.com/lz4/lz4/blob/c609c16aed95ed339e142535b1b270e7b9e24ac1/doc/lz4_Block_format.md#lz4-block-format-description

  2. added
    invalidThis doesn't seem right
    and removed
    bugSomething isn't working
    on Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions