{"record":{"id":"03e0726cf529200c","repo":"ppy/osu","slug":"unknown-file-format-no-content","errorCode":null,"errorMessage":"Unknown file format (no content)","messagePattern":"Unknown file format \\(no content\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"osu.Game/Beatmaps/Formats/Decoder.cs","lineNumber":73,"sourceCode":"            where T : new()\r\n        {\r\n            ArgumentNullException.ThrowIfNull(stream);\r\n\r\n            if (!decoders.TryGetValue(typeof(T), out var typedDecoders))\r\n                throw new IOException(@\"Unknown decoder type\");\r\n\r\n            // start off with the first line of the file\r\n            string? line = stream.PeekLine()?.Trim();\r\n\r\n            while (line != null && line.Length == 0)\r\n            {\r\n                // consume the previously peeked empty line and advance to the next one\r\n                stream.ReadLine();\r\n                line = stream.PeekLine()?.Trim();\r\n            }\r\n\r\n            if (line == null)\r\n                throw new IOException(\"Unknown file format (no content)\");\r\n\r\n            var decoder = typedDecoders.Where(d => line.StartsWith(d.Key, StringComparison.InvariantCulture)).Select(d => d.Value).FirstOrDefault();\r\n\r\n            // it's important the magic does NOT get consumed here, since sometimes it's part of the structure\r\n            // (see JsonBeatmapDecoder - the magic string is the opening brace)\r\n            // decoder implementations should therefore not die on receiving their own magic\r\n            if (decoder != null)\r\n                return (Decoder<T>)decoder.Invoke(line);\r\n\r\n            if (!fallback_decoders.TryGetValue(typeof(T), out var fallbackDecoder))\r\n                throw new IOException($\"Unknown file format ({line})\");\r\n\r\n            return (Decoder<T>)fallbackDecoder.Invoke();\r\n        }\r\n\r\n        /// <summary>\r\n        /// Registers an instantiation function for a <see cref=\"Decoder\"/>.\r\n        /// </summary>\r","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/ppy/osu/blob/d9c73e12adff2feaae4a3e158d36fe5883faf6ca/osu.Game/Beatmaps/Formats/Decoder.cs#L55-L91","documentation":"Thrown by Decoder.GetDecoder when the input stream is empty or contains only whitespace/blank lines. The method peeks and consumes lines looking for the first non-empty content to identify the format magic; if PeekLine returns null (end of stream) before any content is found, the file is treated as having no content.","triggerScenarios":"Calling Decoder.GetDecoder<T>(stream) on a LineBufferedReader whose underlying stream is zero-length, or contains only empty lines. This commonly happens when a beatmap or storyboard .osu/.osb file is empty or truncated to zero bytes.","commonSituations":"A partially-downloaded beatmap where the .osu file is empty; a file that was created but never written to; a stream whose Position was left at the end after a previous read; importing a corrupt archive where a beatmap file decompresses to zero bytes.","solutions":["Check that the stream/file has a non-zero length before passing it to GetDecoder.","If the file is on disk, verify File.Exists and new FileInfo(path).Length > 0 before decoding.","If the stream was previously read, reset stream.Position = 0 before decoding.","Re-download or re-extract the beatmap if the file is truncated."],"exampleFix":"// before\nusing var reader = new LineBufferedReader(stream);\nvar decoder = Decoder.GetDecoder<Beatmap>(reader); // throws if stream is empty\n\n// after\nif (stream.Length == 0)\n    throw new InvalidDataException(\"Cannot decode an empty beatmap stream\");\nusing var reader = new LineBufferedReader(stream);\nvar decoder = Decoder.GetDecoder<Beatmap>(reader);","handlingStrategy":"validation","validationCode":"// Check stream length before decoding\nif (stream.Length == 0)\n    throw new InvalidDataException(\"Stream is empty — cannot decode\");\nusing var reader = new LineBufferedReader(stream);\nvar decoder = Decoder.GetDecoder<Beatmap>(reader);","typeGuard":null,"tryCatchPattern":"try\n{\n    decoder = Decoder.GetDecoder<Beatmap>(reader);\n}\ncatch (IOException ex) when (ex.Message.Contains(\"no content\"))\n{\n    Logger.Log(\"Beatmap file is empty or truncated\", LoggingTarget.Database);\n}","preventionTips":["Verify file/stream length is non-zero before decoding.","Reset stream.Position to 0 if the stream was previously read.","Validate downloaded files aren't zero-length before attempting import."],"tags":["decoder","empty-file","osu-format","io"],"backgroundTag":null,"analyzedSha":"d9c73e12adff2feaae4a3e158d36fe5883faf6ca","analyzedAt":"2026-08-13T14:12:54.015Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}