{"record":{"id":"b2f4e902c134991f","repo":"iOfficeAI/AionUi","slug":"image-file-not-found-searched-paths-possiblepa","errorCode":null,"errorMessage":"Image file not found. Searched paths:\n${possiblePaths.map((p) => `- ${p}`).join('\\n')}\\n\\nPlease ensure the image file exists and has a valid image extension (.jpg, .png, .gif, .webp, etc.)","messagePattern":"Image file not found\\. Searched paths:\n(.+?)`\\)\\.join\\('\\\\n'\\)\\}\\\\n\\\\nPlease ensure the image file exists and has a valid image extension \\(\\.jpg, \\.png, \\.gif, \\.webp, etc\\.\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/desktop/src/common/chat/imageGenCore.ts","lineNumber":189,"sourceCode":"    const base64Data = await fileToBase64(fullPath);\n    const mimeType = getImageMimeType(fullPath);\n    return {\n      type: 'image_url',\n      image_url: { url: `data:${mimeType};base64,${base64Data}`, detail: 'auto' },\n    };\n  } catch (error) {\n    const errorMessage = error instanceof Error ? error.message : String(error);\n\n    if (\n      errorMessage.includes('Path traversal blocked') ||\n      errorMessage.includes('Image file not found') ||\n      errorMessage.includes('not a supported image type')\n    ) {\n      throw error;\n    }\n\n    const possiblePaths = [imageUri, path.resolve(workspaceDir, imageUri)].filter((p, i, arr) => arr.indexOf(p) === i);\n    throw new Error(\n      `Image file not found. Searched paths:\\n${possiblePaths.map((p) => `- ${p}`).join('\\n')}\\n\\nPlease ensure the image file exists and has a valid image extension (.jpg, .png, .gif, .webp, etc.)`,\n      { cause: error }\n    );\n  }\n}\n\n// ===== Core Execution =====\n\nexport interface ImageGenParams {\n  prompt: string;\n  image_uris?: string[] | string;\n}\n\nexport interface ImageGenResult {\n  success: boolean;\n  text: string;\n  imagePath?: string;\n  relativeImagePath?: string;","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/iOfficeAI/AionUi/blob/711aa0550ee183ea495dc33e2c05c7943b70a60a/packages/desktop/src/common/chat/imageGenCore.ts#L171-L207","documentation":"Thrown by processImageUri in imageGenCore.ts when the image URI passed to the message cannot be resolved to an existing file on disk. The function tries the raw URI and the URI resolved against the workspace directory, and when neither exists (and the underlying error is not a 'not a supported image type' error), it throws with the list of searched paths and the original error attached as cause.","triggerScenarios":"Calling an image-generation/send-message API with an imageUri that is a relative filename not present in the working directory, a stale absolute path from a previous session, a file that was deleted or moved, or a path with a typo or missing image extension. Only fired when fs access fails and the error message does not include ENOENT-alternatives like 'not a supported image type'.","commonSituations":"Restarting the app after temp image files were cleaned up; referencing generated images by relative path while the process cwd differs from the workspace dir; user deleting attachments from disk while the chat still references them; URI encoding issues (%20 spaces) making the resolved path not match the real file.","solutions":["Verify the file exists at one of the searched paths printed in the error message","If using a relative path, make sure it is relative to workspaceDir or pass an absolute path","Check the filename spelling, extension (.jpg/.png/.gif/.webp), and that it was not deleted or moved","If the path contains encoded characters, decode it (decodeURIComponent) before passing it in","Re-attach or regenerate the image so a fresh, existing path is used"],"exampleFix":"// before\nawait processImageUri('img-out/pic1.png', workspaceDir);\n\n// after\nimport path from 'node:path';\nconst abs = path.resolve(workspaceDir, 'img-out', 'pic1.png');\nif (!fs.existsSync(abs)) throw new Error(`missing image: ${abs}`);\nawait processImageUri(abs, workspaceDir);","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\n\nconst findImage = (uri: string, workspaceDir: string): string | null => {\n  const candidates = [uri, path.resolve(workspaceDir, uri)];\n  return candidates.find((p) => fs.existsSync(p) && fs.statSync(p).isFile()) ?? null;\n};\n\nconst resolved = findImage(imageUri, workspaceDir);\nif (!resolved) {\n  // show picker / regenerate instead of calling processImageUri\n}\nawait processImageUri(resolved!, workspaceDir);","typeGuard":"const isExistingImagePath = (p: string): boolean =>\n  /\\.(jpe?g|png|gif|webp)$/i.test(p) && fs.existsSync(p);","tryCatchPattern":"try {\n  await processImageUri(uri, workspaceDir);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Image file not found')) {\n    // prompt user to re-attach the image; cause has the original fs error\n    logger.warn('image missing', err.cause);\n  } else throw err;\n}","preventionTips":["Store and pass absolute paths for chat attachments","Validate existence + extension before adding an image to a message","Re-verify paths after app restart since temp dirs get cleaned","Decode URI components before resolving file paths"],"tags":["filesystem","image","path-resolution","chat"],"backgroundTag":"file-not-found","analyzedSha":"711aa0550ee183ea495dc33e2c05c7943b70a60a","analyzedAt":"2026-08-28T07:56:06.558Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}