{"record":{"id":"db5ecd34959ba41b","repo":"LykosAI/StabilityMatrix","slug":"uri-scheme-is-not-supported","errorCode":null,"errorMessage":"Uri scheme is not supported","messagePattern":"Uri scheme is not supported","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/Controls/VendorLabs/Cache/CacheBase.cs","lineNumber":552,"sourceCode":"\n                    if (instance != null)\n                    {\n                        break;\n                    }\n                }\n                catch (FileNotFoundException) { }\n            }\n\n            // Cache\n            if (instance != null && InMemoryFileStorage?.MaxItemCount > 0)\n            {\n                var msi = new InMemoryStorageItem<T>(fileName, DateTime.Now, instance);\n                InMemoryFileStorage?.SetItem(msi);\n            }\n        }\n        else\n        {\n            throw new ArgumentException(\"Uri scheme is not supported\", nameof(uri));\n        }\n\n        return instance;\n    }\n\n    [DebuggerDisableUserUnhandledExceptions]\n    private async Task<T?> DownloadFileAsync(\n        Uri uri,\n        string baseFile,\n        bool preCacheOnly,\n        CancellationToken cancellationToken\n    )\n    {\n        var instance = default(T);\n\n        Debug.WriteLine($\"CacheBase Getting: {uri}\");\n\n        using var ms = new MemoryStream();","sourceCodeStart":534,"sourceCodeEnd":570,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/Controls/VendorLabs/Cache/CacheBase.cs#L534-L570","documentation":"CacheBase.GetFromCacheOrDownloadAsync inspects uri.Scheme to decide between local file and web download paths; when the scheme matches neither supported branch it throws ArgumentException('Uri scheme is not supported', nameof(uri)). The cache layer only supports the URI schemes it explicitly handles.","triggerScenarios":"Passing a URI with an unsupported scheme (e.g. avares://, ftp://, data:, or a relative path without scheme) to the image/file cache's request path.","commonSituations":"Feeding Avalonia resource URIs into a cache designed for http/local-file URIs; malformed URLs lacking a scheme; switching image sources from web to embedded resources without bypassing the cache.","solutions":["Use http:// or https:// (or the supported local-path scheme) for cached downloads","Handle avares:// resources separately via AssetLoader instead of the cache","Validate Uri.TryCreate and the scheme before calling the cache","Normalize the URI (add scheme) before caching"],"exampleFix":"// before\ncache.GetFromCacheOrDownloadAsync(new Uri(\"avares://App/Assets/x.png\"));\n// after\nvar bmp = AssetLoader.Open(new Uri(\"avares://App/Assets/x.png\"));","handlingStrategy":"validation","validationCode":"if (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps && !uri.IsFile)\n    throw new ArgumentException($\"Unsupported scheme {uri.Scheme} for cache\", nameof(uri));","typeGuard":"bool IsCacheableUri(Uri u) => u.Scheme is \"http\" or \"https\" or \"file\";","tryCatchPattern":"try { await cache.GetFromCacheOrDownloadAsync(uri); }\ncatch (ArgumentException ex) { Log.Error(ex, \"Unsupported scheme for {Uri}\", uri); }","preventionTips":["Normalize URIs to http(s)/file before caching","Route resource (avares) URIs through AssetLoader, not the cache","Use Uri.TryCreate and check Scheme before calling"],"tags":["cache","uri","unsupported-scheme","argument"],"backgroundTag":"unsupported-operation","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}