{"record":{"id":"6a8e57e778e5dd50","repo":"JosefNemec/Playnite","slug":"playnite-uri-missing-parameters","errorCode":null,"errorMessage":"playnite:// uri missing parameters.","messagePattern":"playnite:// uri missing parameters\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"source/Playnite/PlayniteUriHandler.cs","lineNumber":65,"sourceCode":"\r\n            Handlers.Add(source, handler);\r\n        }\r\n\r\n        public void RemoveSource(string source)\r\n        {\r\n            var handler = Handlers.FirstOrDefault(a => a.Key.Equals(source, StringComparison.OrdinalIgnoreCase));\r\n            if (handler.Value != null)\r\n            {\r\n                Handlers.Remove(handler.Key);\r\n            }\r\n        }\r\n\r\n        public static (string source, string[] arguments) ParseUri(string uri)\r\n        {\r\n            var split = uri.Split(uriSplitter, StringSplitOptions.RemoveEmptyEntries);\r\n            if (split.Length < 2)\r\n            {\r\n                throw new Exception(\"playnite:// uri missing parameters.\");\r\n            }\r\n\r\n            var source = split[1];\r\n            var arguments = new string[0];\r\n            if (split.Length > 2)\r\n            {\r\n                arguments = split.Skip(2).Select(a => HttpUtility.UrlDecode(a)).ToArray();\r\n            }\r\n\r\n            return (source, arguments);\r\n        }\r\n\r\n        internal void ProcessUri(string uri)\r\n        {\r\n            logger.Info($\"Processing Playnite URI {uri}\");\r\n            try\r\n            {\r\n                var (source, arguments) = ParseUri(uri);\r","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/JosefNemec/Playnite/blob/5911f4e964e628aa7a69c2030ab35101afa63067/source/Playnite/PlayniteUriHandler.cs#L47-L83","documentation":"Thrown by PlayniteUriHandler.ParseUri when splitting a playnite:// URI yields fewer than 2 non-empty segments — i.e. the URI has no command after the scheme. A valid playnite URI must contain at least a source (e.g. playnite://source/...), so fewer segments means the URI is malformed.","triggerScenarios":"ParseUri receives a string like 'playnite://' or 'playnite://playnite' that, after splitting on uriSplitter and removing empties, leaves 0 or 1 segment. Happens with truncated, hand-typed, or malformed invocations.","commonSituations":"External application or shortcut launches a bare playnite:// URI without arguments; URI was constructed/encoded incorrectly; an addon registered a handler but the caller sent an empty command.","solutions":["Validate the URI format (contains at least a source segment) before calling ParseUri.","Construct playnite URIs using a helper that always appends the source and arguments.","Catch the exception at the URI entry point and log/ignore malformed invocations."],"exampleFix":"// before\nvar split = uri.Split(uriSplitter, StringSplitOptions.RemoveEmptyEntries);\nif (split.Length < 2) { throw new Exception(\"playnite:// uri missing parameters.\"); }\n\n// after\nvar split = uri.Split(uriSplitter, StringSplitOptions.RemoveEmptyEntries);\nif (split.Length < 2) {\n    logger.Warn($\"Malformed playnite URI ignored: {uri}\");\n    return (null, Array.Empty<string>());\n}","handlingStrategy":"validation","validationCode":"// Validate URI shape before parsing.\nvar segs = uri.Split(new[]{\"playnite://\"}, StringSplitOptions.RemoveEmptyEntries);\nif (segs.Length == 0 || !segs[0].Contains(\"/\")) { logger.Warn($\"Malformed playnite URI: {uri}\"); return; }","typeGuard":"static bool IsValidPlayniteUri(string uri) =>\n    !uri.IsNullOrEmpty() && uri.Split(uriSplitter, StringSplitOptions.RemoveEmptyEntries).Length >= 2;","tryCatchPattern":"try { var (source, args) = PlayniteUriHandler.ParseUri(uri); }\ncatch (Exception ex) when (ex.Message.Contains(\"missing parameters\")) { logger.Warn($\"Ignored malformed URI: {uri}\"); }","preventionTips":["Always construct playnite URIs with at least a source segment.","Sanitize/ignore bare playnite:// invocations at the OS entry point.","Log ignored URIs to spot misbehaving callers."],"tags":["uri","parsing","validation","handler"],"backgroundTag":null,"analyzedSha":"5911f4e964e628aa7a69c2030ab35101afa63067","analyzedAt":"2026-08-13T17:38:25.713Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}