{"record":{"id":"327c56a045054e2e","repo":"JosefNemec/Playnite","slug":"url-file-doesn-t-have-shortcut-definition-section","errorCode":null,"errorMessage":"URL file doesn't have shortcut definition section.","messagePattern":"URL file doesn't have shortcut definition section\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/Extensions/GameExtensions.cs","lineNumber":122,"sourceCode":"                        game.Icon = iconPath;\r\n                    }\r\n                    else if (iconPath.Contains(\"Program Files (x86)\"))\r\n                    {\r\n                        iconPath = iconPath.Replace(\"Program Files (x86)\", \"Program Files\");\r\n                        if (File.Exists(iconPath))\r\n                        {\r\n                            game.Icon = iconPath;\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n            else if (string.Equals(Path.GetExtension(path), \".url\", StringComparison.OrdinalIgnoreCase))\r\n            {\r\n                var urlData = IniParser.Parse(File.ReadAllLines(path));\r\n                var shortcut = urlData[\"InternetShortcut\"];\r\n                if (shortcut == null)\r\n                {\r\n                    throw new Exception(\"URL file doesn't have shortcut definition section.\");\r\n                }\r\n\r\n                game.Name = Path.GetFileNameWithoutExtension(path);\r\n                game.Icon = shortcut[\"IconFile\"];\r\n                game.GameActions = new System.Collections.ObjectModel.ObservableCollection<GameAction>\r\n                {\r\n                    new GameAction()\r\n                    {\r\n                        Type = GameActionType.URL,\r\n                        Path = shortcut[\"URL\"],\r\n                        IsPlayAction = true,\r\n                        Name = game.Name\r\n                    }\r\n                };\r\n            }\r\n            else\r\n            {\r\n                var file = new FileInfo(path);\r","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/Extensions/GameExtensions.cs#L104-L140","documentation":"Thrown when parsing a .url file (Internet Shortcut) whose INI content lacks the required [InternetShortcut] section. GetGameFromExecutable reads the file via IniParser and indexes urlData[\"InternetShortcut\"]; a null section means the file is malformed or is not actually a URL shortcut.","triggerScenarios":"GetGameFromExecutable is called on a .url file whose contents do not contain an [InternetShortcut] header — e.g. a renamed text file, a truncated/corrupt shortcut, or a .url produced by a non-standard tool.","commonSituations":"User selected a .url file that is actually a different format; the shortcut was partially written or edited manually; encoding issues strip the section header.","solutions":["Pre-parse and validate that the .url file contains an [InternetShortcut] section before calling GetGameFromExecutable.","Reject non-standard .url files at the import UI with a clear message.","If the file is suspect, read and inspect its first lines for the section header."],"exampleFix":"// before\nvar shortcut = urlData[\"InternetShortcut\"];\nif (shortcut == null) { throw new Exception(\"URL file doesn't have shortcut definition section.\"); }\n\n// after — caller pre-validation\nvar lines = File.ReadAllLines(path);\nif (!lines.Any(l => l.Trim() == \"[InternetShortcut]\")) {\n    logger.Warn($\"{path} is not a valid Internet Shortcut.\");\n    return null;\n}","handlingStrategy":"validation","validationCode":"// Validate .url structure before import.\nif (Path.GetExtension(path).Equals(\".url\", StringComparison.OrdinalIgnoreCase)) {\n    var text = File.ReadAllText(path);\n    if (!text.Contains(\"[InternetShortcut]\")) { logger.Warn($\"Invalid .url: {path}\"); return null; }\n}","typeGuard":"static bool IsValidUrlShortcut(string path) =>\n    File.Exists(path) && File.ReadAllText(path).Contains(\"[InternetShortcut]\");","tryCatchPattern":null,"preventionTips":["Inspect .url file headers during import validation.","Reject malformed shortcuts at the UI with a clear message.","Treat parsing failures as user warnings, not crashes."],"tags":["filesystem","game-import","parsing","validation"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}