{"record":{"id":"e49425025fc60617","repo":"ppy/osu","slug":"input-lzma-is-too-short","errorCode":null,"errorMessage":"input .lzma is too short","messagePattern":"input \\.lzma is too short","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs","lineNumber":174,"sourceCode":"\r\n            if (decodedRank != null)\r\n                score.ScoreInfo.Rank = decodedRank.Value;\r\n\r\n            // before returning for database import, we must restore the database-sourced BeatmapInfo.\r\n            // if not, the clone operation in GetPlayableBeatmap will cause a dereference and subsequent database exception.\r\n            score.ScoreInfo.BeatmapInfo = workingBeatmap.BeatmapInfo;\r\n            score.ScoreInfo.BeatmapHash = workingBeatmap.BeatmapInfo.Hash;\r\n\r\n            return score;\r\n        }\r\n\r\n        private void readCompressedData(byte[] data, Action<StreamReader> readFunc)\r\n        {\r\n            using (var replayInStream = new MemoryStream(data))\r\n            {\r\n                byte[] properties = new byte[5];\r\n                if (replayInStream.Read(properties, 0, 5) != 5)\r\n                    throw new IOException(\"input .lzma is too short\");\r\n\r\n                long outSize = 0;\r\n\r\n                for (int i = 0; i < 8; i++)\r\n                {\r\n                    int v = replayInStream.ReadByte();\r\n                    if (v < 0)\r\n                        throw new IOException(\"Can't Read 1\");\r\n\r\n                    outSize |= (long)(byte)v << (8 * i);\r\n                }\r\n\r\n                long compressedSize = replayInStream.Length - replayInStream.Position;\r\n\r\n                using (var lzma = LzmaStream.Create(properties, replayInStream, compressedSize, outSize))\r\n                using (var reader = new StreamReader(lzma))\r\n                    readFunc(reader);\r\n            }\r","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs#L156-L192","documentation":"Thrown inside readCompressedData when the LZMA replay payload cannot supply the first 5 bytes (the LZMA properties header). The stream is truncated before the decoder can even begin, so the replay is structurally invalid. This is a hard data-integrity failure, not a decode problem.","triggerScenarios":"Replay data array passed to readCompressedData is shorter than 5 bytes, or is empty. Happens with partially downloaded/extracted .osr replay files or a truncated embedded replay stream.","commonSituations":"Corrupt .osr file download (network cut mid-transfer), replay writer produced a zero-length compressed blob, or the wrong byte slice was handed to the decoder.","solutions":["Verify the source .osr file size is non-trivially larger than 5 bytes and re-download/re-extract if it is truncated.","Check the upstream writer/encoder to confirm it flushes the full LZMA blob before closing the stream.","Catch IOException around the decode path and report a 'corrupt replay' user message rather than letting it propagate.","If importing many replays, quarantine files that fail this check instead of aborting the whole import."],"exampleFix":"// before\nif (replayInStream.Read(properties, 0, 5) != 5)\n    throw new IOException(\"input .lzma is too short\");\n\n// after (caller-side guard)\nif (data.Length < 13) // 5 props + 8 size bytes minimum\n    throw new IOException($\"Replay payload too short ({data.Length} bytes); file is corrupt.\");","handlingStrategy":"validation","validationCode":"if (data == null || data.Length < 13)\n    throw new IOException(\"Replay payload is truncated; cannot decode.\");","typeGuard":null,"tryCatchPattern":"try { readCompressedData(data, readFunc); }\ncatch (IOException) { /* mark replay corrupt, skip import */ }","preventionTips":["Pre-validate replay payload length before LZMA decode.","Quarantine short/corrupt files during batch import.","Verify replay file integrity (checksum/size) on download."],"tags":["replay","lzma","io","corrupt-data","score-decoder"],"backgroundTag":null,"analyzedSha":"d9c73e12adff2feaae4a3e158d36fe5883faf6ca","analyzedAt":"2026-08-13T14:12:54.015Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}