{"record":{"id":"e582dcf2b06c6c88","repo":"dotnet/maui","slug":"uri","errorCode":null,"errorMessage":"uri","messagePattern":"uri","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/Android/AppCompat/Platform.cs","lineNumber":871,"sourceCode":"\n\t\t\t\tif (uri.LocalPath.StartsWith(\"/local\"))\n\t\t\t\t{\n\t\t\t\t\tfilePath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), uri.LocalPath.Substring(7));\n\t\t\t\t}\n\t\t\t\telse if (uri.LocalPath.StartsWith(\"/temp\"))\n\t\t\t\t{\n\t\t\t\t\tfilePath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), uri.LocalPath.Substring(6));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tthrow new ArgumentException(\"Invalid Uri\", \"Source\");\n\t\t\t\t}\n\n\t\t\t\treturn filePath;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tthrow new ArgumentException(\"uri\");\n\t\t\t}\n\n\t\t}\n\t}\n}\n","sourceCodeStart":853,"sourceCodeEnd":877,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/Android/AppCompat/Platform.cs#L853-L877","documentation":"Thrown by Platform.ResolveMsAppDataUri when the URI's scheme is not ms-appdata. The method is specifically for resolving ms-appdata URIs; any other scheme (http, file, content, etc.) is rejected by the outer else branch. The error message is terse ('uri') because the method assumes callers pre-filter by scheme.","triggerScenarios":"Passing an http(s), file://, content://, or plain relative URI to ResolveMsAppDataUri. The outer if checks uri.Scheme == \"ms-appdata\" and the else branch throws unconditionally.","commonSituations":"Generic image/file loading code that routes all URIs through ResolveMsAppDataUri without checking the scheme. Cross-platform code that uses file:// on Android but ms-appdata on UWP, calling the same resolver.","solutions":["Only call ResolveMsAppDataUri after confirming uri.Scheme == \"ms-appdata\".","Route non-ms-appdata URIs to the appropriate resolver (e.g., file:// to a file path resolver, http:// to a network image loader).","Wrap the call in a scheme-based switch to dispatch to the correct handler."],"exampleFix":"// before\nvar uri = new Uri(\"file:///data/app/photo.png\");\nvar path = Platform.ResolveMsAppDataUri(uri); // throws\n\n// after\nstring path;\nif (uri.Scheme == \"ms-appdata\")\n    path = Platform.ResolveMsAppDataUri(uri);\nelse if (uri.IsFile)\n    path = uri.LocalPath;\nelse\n    throw new NotSupportedException($\"Unsupported scheme: {uri.Scheme}\");","handlingStrategy":"validation","validationCode":"if (uri.Scheme != \"ms-appdata\")\n    throw new ArgumentException($\"Expected ms-appdata scheme, got {uri.Scheme}.\", nameof(uri));\nvar path = Platform.ResolveMsAppDataUri(uri);","typeGuard":"static bool IsMsAppDataUri(Uri uri) => uri?.Scheme == \"ms-appdata\";","tryCatchPattern":null,"preventionTips":["Dispatch URIs by scheme before calling ResolveMsAppDataUri.","Create a URI resolver facade that hides platform-specific resolvers from callers.","Add a scheme-check unit test for the image/file source helper."],"tags":["android","uri","ms-appdata","scheme","platform"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}