iOfficeAI/AionUi · error · Error
Image file not found
Error message
Image file not found
What it means
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.
Source
Thrown at packages/desktop/src/renderer/pages/conversation/Preview/components/viewers/ImageViewer.tsx:53
return;
}
if (!fileRef && !file_path) {
setImageSrc('');
setLoading(false);
return;
}
try {
setLoading(true);
setError(null);
// Prefer the ChatFileRef identity (data-URL from /api/fs/content); fall back
// to the legacy {path, workspace} image endpoint for callers not yet migrated.
const base64 = fileRef
? await ipcBridge.fs.readContent.invoke({ file: fileRef, encoding: 'dataurl' })
: await ipcBridge.fs.getImageBase64.invoke({ path: file_path!, workspace });
if (!base64) {
throw new Error('Image file not found');
}
if (!isMounted) return;
setImageSrc(base64);
} catch (err) {
if (!isMounted) return;
console.error('[ImagePreview] Failed to load image:', err);
setError(t('messages.imageLoadFailed', { defaultValue: 'Failed to load image' }));
} finally {
if (isMounted) {
setLoading(false);
}
}
};
void loadImage();
return () => {
isMounted = false;View on GitHub (pinned to 711aa0550e)
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
Defensive patterns
Strategy: try-catch
Validate before calling
if (!fileRef && !file_path) return; // nothing to load
Try / catch
try {
const b64 = fileRef
? await ipcBridge.fs.readContent.invoke({ file: fileRef, encoding: 'dataurl' })
: await ipcBridge.fs.getImageBase64.invoke({ path: file_path!, workspace });
if (!b64) return; // show placeholder instead of throwing
setImageSrc(b64);
} catch (err) {
console.error('[ImagePreview] load failed', err);
setFailed(true); // render fallback UI
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Conversation history referencing attachments cleaned from disk, workspace switched after the message was created, or files on removable/network storage that are offline.
Related errors
- File data not found
- Image file not found. Searched paths: ${possiblePaths.map((p
- fork returned no conversation
- scm port not configured
- result?.msg || fallbackMessage
AI-assisted analysis of iOfficeAI/AionUi@711aa0550e (2026-08-28).
Data as JSON: /api/errors/0d96e4c7b07513bb.
Report an issue: GitHub.