EllanJiang/GameFramework · error · GameFrameworkException

Decompressed stream is invalid.

Error message

Decompressed stream is invalid.

What it means

Utility.Decompress validates its arguments before attempting decompression. This GameFrameworkException is thrown when the caller passes a null decompressedStream to Decompress(byte[] bytes, int offset, int length, Stream decompressedStream). The framework requires a valid destination stream to write the decompressed data into.

Solutions

  1. Create a valid destination stream (e.g. new MemoryStream()) and pass it to Decompress.
  2. Add a null check on the stream before calling Decompress to fail fast with a clearer message.
  3. If the stream comes from another method, verify that method cannot return null.

Example fix

// before
Stream output = GetOutput(); // may return null
Utility.Decompress(data, 0, data.Length, output);

// after
using (var output = new MemoryStream())
{
    Utility.Decompress(data, 0, data.Length, output);
    ...
}
Defensive patterns

Strategy: validation

Validate before calling

if (output == null) throw new ArgumentException("decompressedStream must be created before Decompress");

Type guard

bool IsValidStream(Stream s) => s != null;

Try / catch

try { Utility.Decompress(bytes, offset, length, output); } catch (GameFrameworkException ex) { /* output stream was null or invalid */ }

Prevention

When it happens

Trigger: Calling Utility.Decompress(bytes, offset, length, null) — i.e. passing null as the decompressedStream parameter.

Common situations: Developers caching a stream in a field that was never initialized, refactoring code so the stream is disposed/set to null before the decompress call, or forgetting to create the MemoryStream intended to receive the output.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/dc725510ab7724be. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Utility/Utility.Compression.cs:267

            {
                if (s_CompressionHelper == null)
                {
                    throw new GameFrameworkException("Compressed helper is invalid.");
                }

                if (bytes == null)
                {
                    throw new GameFrameworkException("Bytes is invalid.");
                }

                if (offset < 0 || length < 0 || offset + length > bytes.Length)
                {
                    throw new GameFrameworkException("Offset or length is invalid.");
                }

                if (decompressedStream == null)
                {
                    throw new GameFrameworkException("Decompressed stream is invalid.");
                }

                try
                {
                    return s_CompressionHelper.Decompress(bytes, offset, length, decompressedStream);
                }
                catch (Exception exception)
                {
                    if (exception is GameFrameworkException)
                    {
                        throw;
                    }

                    throw new GameFrameworkException(Text.Format("Can not decompress with exception '{0}'.", exception), exception);
                }
            }

            /// <summary>

View on GitHub (pinned to d0c010b051)