{"record":{"id":"b9c5954ec0a9e0c3","repo":"LykosAI/StabilityMatrix","slug":"file-normalizedpath-filepath-was-not-found","errorCode":null,"errorMessage":"File {normalizedPath} ({filePath}) was not found","messagePattern":"File (.+?) \\((.+?)\\) was not found","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/Extensions/ClipboardExtensions.cs","lineNumber":40,"sourceCode":"    }\n\n    /// <summary>\n    /// Set file paths to the clipboard.\n    /// </summary>\n    /// <exception cref=\"IOException\">Thrown if unable to get file from path</exception>\n    public static async Task SetFileDataObjectAsync(this IClipboard clipboard, IEnumerable<string> filePaths)\n    {\n        var files = new List<IStorageFile>();\n\n        foreach (var filePath in filePaths)\n        {\n            // Normalize path that might have come from avalonia storage provider already\n            var normalizedPath = filePath.StripStart(\"file:///\").StripStart(\"file://\");\n\n            var file = await StorageProvider.TryGetFileFromPathAsync(normalizedPath);\n            if (file is null)\n            {\n                throw new IOException($\"File {normalizedPath} ({filePath}) was not found\");\n            }\n\n            files.Add(file);\n        }\n\n        if (files.Count == 0)\n        {\n            return;\n        }\n\n        var dataObject = new DataObject();\n        dataObject.Set(DataFormats.Files, files);\n\n        await clipboard.SetDataObjectAsync(dataObject);\n    }\n}\n","sourceCodeStart":22,"sourceCodeEnd":57,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/Extensions/ClipboardExtensions.cs#L22-L57","documentation":"ClipboardExtensions.SetFileDataObjectAsync builds a file list for the system clipboard (DataObject file drop). For each supplied path it normalizes 'file:///' and 'file://' prefixes and asks the StorageProvider to resolve it; if the file does not exist on disk (TryGetFileFromPathAsync returns null), it throws IOException naming both the normalized and original path.","triggerScenarios":"Calling SetFileDataObjectAsync with a path to a file that was deleted or moved before the call, a relative path that is not resolvable by the StorageProvider, a malformed/percent-encoded URI string, or a path outside the app's accessible storage scopes.","commonSituations":"Drag-and-drop handlers caching a file path whose temp file was later cleaned up; passing URLs from a web view whose target file was never downloaded; sandboxed (flatpak/macos) apps receiving paths they cannot access.","solutions":["Verify File.Exists / TryGetFileFromPathAsync on each path before calling SetFileDataObjectAsync and filter out missing files.","Convert relative paths to absolute, and pre-decode 'file://' URIs before passing them in.","Catch the IOException and surface a 'file not found' message instead of letting it bubble.","If running sandboxed, grant access or copy the file into app-accessible storage first."],"exampleFix":"// before\nawait clipboard.SetFileDataObjectAsync(paths);\n\n// after\nvar existing = paths.Where(p => File.Exists(p.StripStart(\"file:///\").StripStart(\"file://\"))).ToList();\nif (existing.Count > 0)\n    await clipboard.SetFileDataObjectAsync(existing);","handlingStrategy":"validation","validationCode":"var ok = paths.All(p => File.Exists(p.StripStart(\"file:///\").StripStart(\"file://\")));","typeGuard":null,"tryCatchPattern":"try\n{\n    await clipboard.SetFileDataObjectAsync(paths);\n}\ncatch (IOException ex)\n{\n    notifier.ShowError($\"Cannot copy to clipboard: {ex.Message}\");\n}","preventionTips":["Resolve and verify file existence right before clipboard calls","Normalize file:// URIs before passing paths","Watch for temp files being deleted while queued for clipboard","Account for sandbox storage-access restrictions"],"tags":["avalonia","clipboard","io","file-not-found"],"backgroundTag":"file-not-found","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"}