{"record":{"id":"0d96e4c7b07513bb","repo":"iOfficeAI/AionUi","slug":"image-file-not-found-0d96e4","errorCode":null,"errorMessage":"Image file not found","messagePattern":"Image file not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/desktop/src/renderer/pages/conversation/Preview/components/viewers/ImageViewer.tsx","lineNumber":53,"sourceCode":"        return;\n      }\n\n      if (!fileRef && !file_path) {\n        setImageSrc('');\n        setLoading(false);\n        return;\n      }\n\n      try {\n        setLoading(true);\n        setError(null);\n        // Prefer the ChatFileRef identity (data-URL from /api/fs/content); fall back\n        // to the legacy {path, workspace} image endpoint for callers not yet migrated.\n        const base64 = fileRef\n          ? await ipcBridge.fs.readContent.invoke({ file: fileRef, encoding: 'dataurl' })\n          : await ipcBridge.fs.getImageBase64.invoke({ path: file_path!, workspace });\n        if (!base64) {\n          throw new Error('Image file not found');\n        }\n        if (!isMounted) return;\n        setImageSrc(base64);\n      } catch (err) {\n        if (!isMounted) return;\n        console.error('[ImagePreview] Failed to load image:', err);\n        setError(t('messages.imageLoadFailed', { defaultValue: 'Failed to load image' }));\n      } finally {\n        if (isMounted) {\n          setLoading(false);\n        }\n      }\n    };\n\n    void loadImage();\n\n    return () => {\n      isMounted = false;","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/iOfficeAI/AionUi/blob/711aa0550ee183ea495dc33e2c05c7943b70a60a/packages/desktop/src/renderer/pages/conversation/Preview/components/viewers/ImageViewer.tsx#L35-L71","documentation":"loadImage in ImageViewer throws 'Image file not found' when the IPC content read returns empty/falsy — either fs.readContent with a dataurl encoding on a ChatFileRef, or the legacy getImageBase64 endpoint with {path, workspace}. It means the file could not be read as content (missing, unreadable, or unsupported), distinct from an IPC exception which lands in the catch block.","triggerScenarios":"fileRef pointing to a deleted or moved attachment; legacy path-based lookup where workspace is wrong; image larger than a size cap causing the main process to return null; zero-byte file.","commonSituations":"Conversation history referencing attachments cleaned from disk, workspace switched after the message was created, or files on removable/network storage that are offline.","solutions":["Verify the file still exists at fileRef/path inside the expected workspace","Ensure the correct workspace is passed for legacy {path, workspace} calls","Re-attach or re-export the image if the source was deleted","If it recurs for existing files, check main-process logs for the underlying fs read failure"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!fileRef && !file_path) return; // nothing to load","typeGuard":null,"tryCatchPattern":"try {\n  const b64 = fileRef\n    ? await ipcBridge.fs.readContent.invoke({ file: fileRef, encoding: 'dataurl' })\n    : await ipcBridge.fs.getImageBase64.invoke({ path: file_path!, workspace });\n  if (!b64) return; // show placeholder instead of throwing\n  setImageSrc(b64);\n} catch (err) {\n  console.error('[ImagePreview] load failed', err);\n  setFailed(true); // render fallback UI\n}","preventionTips":["Check file existence before opening preview when path is user-supplied","Migrate legacy {path, workspace} callers to ChatFileRef identity","Show a placeholder UI on empty content rather than surfacing an error"],"tags":["image","file-not-found","ipc","preview"],"backgroundTag":"file-read-empty-result","analyzedSha":"711aa0550ee183ea495dc33e2c05c7943b70a60a","analyzedAt":"2026-08-28T07:56:06.558Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}