{"record":{"id":"17a505a73dd42cef","repo":"ppy/osu","slug":"can-t-read-1","errorCode":null,"errorMessage":"Can't Read 1","messagePattern":"Can't Read 1","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs","lineNumber":182,"sourceCode":"\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\n        }\r\n\r\n        /// <summary>\r\n        /// Populates the <see cref=\"ScoreInfo.MaximumStatistics\"/> for a given <see cref=\"ScoreInfo\"/>.\r\n        /// </summary>\r\n        /// <param name=\"score\">The score to populate the statistics of.</param>\r\n        /// <param name=\"workingBeatmap\">The corresponding <see cref=\"WorkingBeatmap\"/>.</param>\r\n        public static void PopulateMaximumStatistics(ScoreInfo score, WorkingBeatmap workingBeatmap)\r","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Game/Scoring/Legacy/LegacyScoreDecoder.cs#L164-L200","documentation":"Thrown while reading the 8-byte little-endian uncompressed-size field of an LZMA replay stream, when ReadByte() returns -1 (EOF) before all 8 bytes are read. The properties header was present but the stream is still truncated within the metadata region. Sibling of the 'input .lzma is too short' check.","triggerScenarios":"The replay byte array contains between 5 and 12 bytes inclusive: enough for the LZMA properties but not enough for the full 8-byte outSize length prefix.","commonSituations":"Partially-overwritten replay file, a writer bug that wrote the properties header then failed before the length field, or manual slicing of a compressed payload that cut mid-header.","solutions":["Validate data.Length >= 13 before entering readCompressedData so the metadata region is guaranteed present.","Re-acquire the replay file from its original source and retry the import.","Wrap the decode in try/catch IOException and skip/quarantine corrupt replays during batch import.","Audit the replay encoder to ensure it writes the full 13-byte header atomically."],"exampleFix":"// before\nint v = replayInStream.ReadByte();\nif (v < 0)\n    throw new IOException(\"Can't Read 1\");\n\n// after (precheck)\nif (data.Length < 13)\n    throw new IOException($\"Replay metadata truncated ({data.Length} bytes); need at least 13.\");","handlingStrategy":"validation","validationCode":"if (data == null || data.Length < 13)\n    throw new IOException($\"Replay metadata truncated: {data?.Length ?? 0} bytes.\");","typeGuard":null,"tryCatchPattern":"try { readCompressedData(data, readFunc); }\ncatch (IOException ex) when (ex.Message.Contains(\"Read 1\")) { /* corrupt replay */ }","preventionTips":["Check data.Length covers the full 13-byte LZMA header before decoding.","Reject incomplete replays at the import boundary.","Audit the replay encoder to write the header atomically."],"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"}