{"record":{"id":"02096620f26f9ade","repo":"Flow-Launcher/Flow.Launcher","slug":"failed-to-get-thumbnail","errorCode":null,"errorMessage":"Failed to get thumbnail","messagePattern":"Failed to get thumbnail","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"Flow.Launcher.Infrastructure/Image/ThumbnailReader.cs","lineNumber":131,"sourceCode":"                try\n                {\n                    imageFactory.GetImage(size, (SIIGBF)options, &hBitmap);\n                }\n                catch (COMException ex) when (options == ThumbnailOptions.ThumbnailOnly &&\n                    (ex.HResult == S_PATHNOTFOUND || ex.HResult == S_EXTRACTIONFAILED))\n                {\n                    // Fallback to IconOnly if extraction fails or files cannot be found\n                    imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);\n                }\n                catch (FileNotFoundException) when (options == ThumbnailOptions.ThumbnailOnly)\n                {\n                    // Fallback to IconOnly if files cannot be found\n                    imageFactory.GetImage(size, (SIIGBF)ThumbnailOptions.IconOnly, &hBitmap);\n                }\n                catch (System.Exception ex)\n                {\n                    // Handle other exceptions\n                    throw new InvalidOperationException(\"Failed to get thumbnail\", ex);\n                }\n            }\n            finally\n            {\n                if (shellItem != null)\n                {\n                    Marshal.ReleaseComObject(shellItem);\n                }\n            }\n\n            return hBitmap;\n        }\n\n        /// <summary>\n        /// Obtains an HBITMAP for a Windows .url shortcut by resolving its IconFile entry and delegating to GetHBitmap.\n        /// </summary>\n        /// <remarks>\n        /// The method parses the .url file as an INI, looks in the \"InternetShortcut\" section for the \"IconFile\" entry,","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/Flow-Launcher/Flow.Launcher/blob/7fc63b07bbaa10a0f0b2601487913fcba9ed24b0/Flow.Launcher.Infrastructure/Image/ThumbnailReader.cs#L113-L149","documentation":"Thrown as InvalidOperationException wrapping any exception from imageFactory.GetImage that is NOT one of the explicitly handled fallback cases (COMException with PATHNOTFOUND/EXTRACTIONFAILED under ThumbnailOnly, or FileNotFoundException under ThumbnailOnly). It is the catch-all for thumbnail extraction failures not covered by the IconOnly fallback path.","triggerScenarios":"GetImage throws an OutOfMemoryException, an access-denied COMException (different HRESULT), an SEHException, or any other exception type while in non-ThumbnailOnly mode (so the fallback clauses don't match); the thumbnail provider crashes for a corrupt media file; insufficient privileges to read the file's thumbnail cache.","commonSituations":"Corrupt image/video/PDF whose thumbnail extractor (e.g. codec) crashes; a file locked exclusively by another process; a shell extension/thumbnail provider that is broken or unregistered; large files whose extractor times out internally.","solutions":["Inspect the InnerException — it carries the original HRESULT/exception that names the failing provider.","Catch this InvalidOperationException at the caller and fall back to a static placeholder icon.","If reproducible for one file, that file's thumbnail provider is likely broken — re-associate or repair the codec.","Run the thumbnail/icon cache rebuild (Disk Cleanup) to clear stale cache entries."],"exampleFix":"// before — catch-all rethrow\ncatch (System.Exception ex)\n{\n    throw new InvalidOperationException(\"Failed to get thumbnail\", ex);\n}\n\n// after — log and return a sentinel so the caller can fall back\ncatch (System.Exception ex)\n{\n    Log.Exception(nameof(ThumbnailReader), $\"GetImage failed for {fileName}\", ex);\n    return HBITMAP.Null;\n}","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try { return ThumbnailReader.GetThumbnail(fileName, w, h, options); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Failed to get thumbnail\"))\n{ Log.Exception(ClassName, $\"Thumbnail failed for {fileName}\", ex.InnerException); return fallbackIcon; }","preventionTips":["Catch InvalidOperationException at the caller and fall back to a placeholder.","Inspect InnerException for the failing provider/HRESULT.","Rebuild the thumbnail/icon cache (Disk Cleanup) if failures are widespread.","Avoid requesting thumbnails for known-corrupt or locked files."],"tags":["image","thumbnail","win32","shell","com"],"backgroundTag":null,"analyzedSha":"7fc63b07bbaa10a0f0b2601487913fcba9ed24b0","analyzedAt":"2026-08-13T14:54:20.914Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}