{"record":{"id":"d3fc0a7c9400ea27","repo":"stride3d/stride","slug":"chunks-with-multiple-passes-are-not-supported","errorCode":null,"errorMessage":"Chunks with multiple passes are not supported.","messagePattern":"Chunks with multiple passes are not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Serialization/Serialization/LZ4/LZ4Stream.cs","lineNumber":298,"sourceCode":"            if (compressedDataBuffer == null || compressedDataBuffer.Length < compressedLength)\n                compressedDataBuffer = new byte[compressedLength];\n            var chunk = ReadBlock(compressedDataBuffer, 0, compressedLength);\n\n            if (chunk != compressedLength) throw new IOException(\"Can't read beyond end of stream.\"); // currupted\n\n            if (!isCompressed)\n            {\n                // swap the buffers\n                (compressedDataBuffer, dataBuffer) = (dataBuffer, compressedDataBuffer);\n                bufferLength = compressedLength;\n            }\n            else\n            {\n                if (dataBuffer == null || dataBuffer.Length < originalLength)\n                    dataBuffer = new byte[originalLength];\n                var passes = (int)flags >> 2;\n                if (passes != 0)\n                    throw new NotSupportedException(\"Chunks with multiple passes are not supported.\");\n                LZ4Codec.Decode(compressedDataBuffer, 0, compressedLength, dataBuffer, 0, originalLength);\n                bufferLength = originalLength;\n            }\n\n            bufferOffset = 0;\n        } while (bufferLength == 0); // skip empty block (shouldn't happen but...)\n\n        return true;\n    }\n\n    #endregion\n\n    #region overrides\n\n    /// <inheritdoc/>\n    public override bool CanRead\n    {\n        get { return compressionMode == CompressionMode.Decompress; }","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Serialization/Serialization/LZ4/LZ4Stream.cs#L280-L316","documentation":"The LZ4 chunk flags can encode multiple compression passes (bits above the Compressed flag). LZ4Stream's decoder only supports single-pass chunks, so a chunk with a nonzero pass count triggers NotSupportedException — the data was written by an unsupported encoder configuration.","triggerScenarios":"Reading a stream produced with chunk flags encoding passes > 0 (multiple compression passes), which this reader version cannot decode.","commonSituations":"Cross-version incompatibility: newer Stride/encoder wrote multi-pass chunks; third-party LZ4 stream producer with different flag semantics; corrupted flags byte that happens to set pass bits.","solutions":["Re-encode the data with a writer that produces single-pass LZ4 chunks (same library version as the reader)","Upgrade the reader/library to a version supporting multi-pass chunks","Inspect the flags byte of the failing chunk to confirm the producer's format"],"exampleFix":"// before\n// file written by newer encoder with multi-pass chunks\nvar s = new LZ4Stream(File.OpenRead(f)); // NotSupportedException\n// after\nvar f2 = RecompressSinglePass(f); // rewrite with matching library version\nvar s = new LZ4Stream(File.OpenRead(f2));","handlingStrategy":"fallback","validationCode":"// read first chunk flags and check pass bits before full read\nvar flags = ReadFirstChunkFlags(path);\nif (((int)flags >> 2) != 0) throw new NotSupportedException(\"Multi-pass LZ4 chunk; re-encode required\");","typeGuard":null,"tryCatchPattern":"try { using var s = new LZ4Stream(File.OpenRead(path)); ... }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"multiple passes\")) { // re-encode with supported writer\n}","preventionTips":["Encode and decode with the same Stride/LZ4Stream version","Configure writers to single-pass compression","Document LZ4 asset provenance (encoder version) with stored files"],"tags":["io","compression","lz4","compatibility"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}