{"record":{"id":"18862a994a3b3dd4","repo":"LykosAI/StabilityMatrix","slug":"file-does-not-exist","errorCode":null,"errorMessage":"File does not exist","messagePattern":"File does not exist","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs","lineNumber":181,"sourceCode":"\n        if (disposing)\n        {\n            ((IPersistentViewProvider)this).AttachedPersistentView = null;\n        }\n    }\n\n    /// <summary>\n    /// Loads image and metadata from a file path\n    /// </summary>\n    /// <remarks>This is safe to call from non-UI threads</remarks>\n    /// <param name=\"filePath\">File path</param>\n    public void LoadImageMetadata(FilePath? filePath)\n    {\n        Logger.Info(\"Loading image metadata from '{Path}'\", filePath?.FullPath);\n\n        if (filePath is not { Exists: true })\n        {\n            throw new FileNotFoundException(\"File does not exist\", filePath?.FullPath);\n        }\n\n        var metadata = ImageMetadata.GetAllFileMetadata(filePath);\n\n        LoadImageMetadata(filePath.FullPath, metadata);\n    }\n\n    /// <summary>\n    /// Loads image and metadata from a LocalImageFile\n    /// </summary>\n    /// <param name=\"localImageFile\">LocalImageFile</param>\n    public void LoadImageMetadata(LocalImageFile localImageFile)\n    {\n        Logger.Info(\"Loading image metadata from LocalImageFile at '{Path}'\", localImageFile.AbsolutePath);\n\n        var metadata = localImageFile.ReadMetadata();\n\n        LoadImageMetadata(localImageFile.AbsolutePath, metadata);","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/Base/InferenceTabViewModelBase.cs#L163-L199","documentation":"LoadImageMetadata loads PNG/image metadata for a dropped or opened file path, but first requires the path be non-null and the file exist. If the FilePath is null or the file is gone, it throws FileNotFoundException with the path as FileName so the caller can report a missing file.","triggerScenarios":"Calling LoadImageMetadata(path) (via Drop or AddTabFromFileAsync) with a null path, a path pointing to a deleted/renamed file, a file on unmounted removable media, or a stale path from a previous session.","commonSituations":"Dragging a file that was deleted before drop completed; opening an image from a temp folder that was cleaned; files on an external drive/network share that disconnected; OS passing a virtual/non-filesystem drop payload.","solutions":["Verify the file exists before calling: File.Exists(path) / path.Exists, and show a 'file not found' dialog otherwise.","Re-pick/re-drag the file — if it was deleted or moved, restore it or browse to its new location.","For drop scenarios, canonicalize the dropped payload to a real filesystem path and bail out early if it isn't one."],"exampleFix":"// before\nvm.LoadImageMetadata(path); // FileNotFoundException if missing\n// after\nif (path is not { Exists: true })\n{\n    Dialogs.ShowDialog(\"File not found\", $\"{path?.FullPath} no longer exists.\");\n    return;\n}\nvm.LoadImageMetadata(path);","handlingStrategy":"validation","validationCode":"if (path is not { Exists: true })\n{\n    Dialogs.ShowDialog(\"File not found\", $\"'{path?.FullPath}' does not exist.\");\n    return;\n}","typeGuard":"bool Loadable(FilePath? p) => p is { Exists: true };","tryCatchPattern":"try { vm.LoadImageMetadata(path); }\ncatch (FileNotFoundException ex) { Dialogs.ShowDialog(\"File not found\", ex.FileName ?? \"unknown path\"); }","preventionTips":["Check File.Exists/path.Exists immediately before opening files from drag-drop or recent-files lists.","Handle dropped items by copying to a stable location before reading metadata.","Don't persist raw temp paths across sessions; verify on restore."],"tags":["file","file-not-found","drag-drop","avalonia"],"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"}