{"record":{"id":"e421b564f33f762c","repo":"stablyai/orca","slug":"file-is-too-large-srcstat-size-1024-1024","errorCode":null,"errorMessage":"File is too large (${(srcStat.size / (1024 * 1024)).toFixed(1)} MB). Max is ${MAX_BYTES / (1024 * 1024)} MB.","messagePattern":"File is too large \\((.+?) MB\\)\\. Max is (.+?) MB\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/main/ipc/pet.ts","lineNumber":205,"sourceCode":"    if (result.canceled || result.filePaths.length === 0) {\n      return null\n    }\n    const src = result.filePaths[0]\n    const classified = classifyFile(src)\n    if (!classified) {\n      throw new Error('Unsupported file. Pick a PNG, APNG, JPG, GIF, WebP, or SVG.')\n    }\n    let srcStat: Awaited<ReturnType<typeof stat>>\n    try {\n      srcStat = await stat(src)\n    } catch {\n      throw new Error('Could not read the selected file.')\n    }\n    if (!srcStat.isFile()) {\n      throw new Error('Selected path is not a file')\n    }\n    if (srcStat.size > MAX_BYTES) {\n      throw new Error(\n        `File is too large (${(srcStat.size / (1024 * 1024)).toFixed(1)} MB). Max is ${MAX_BYTES / (1024 * 1024)} MB.`\n      )\n    }\n\n    const dir = getPetsDir()\n    await mkdir(dir, { recursive: true })\n    const id = randomUUID()\n    // Why: keep the original extension in the on-disk name so pet:read can rebuild the Blob MIME without a separate lookup.\n    const fileName = `${id}${classified.ext}`\n    const dest = join(dir, fileName)\n    try {\n      await copyFile(src, dest)\n    } catch {\n      await rm(dest, { force: true }).catch(() => {})\n      throw new Error('Could not save the pet.')\n    }\n\n    const rawLabel = basename(src, extname(src)).trim()","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/pet.ts#L187-L223","documentation":"Thrown by the pet:import handler when srcStat.size exceeds MAX_BYTES (64 MiB, defined as 64 * 1024 * 1024). The cap exists so a renderer building a Blob URL from the bytes cannot be OOM'd by a multi-gigabyte file. The message includes the actual size and the cap in MB so the user knows how much to shrink.","triggerScenarios":"Selecting an image file larger than 64 MiB — high-resolution photos, uncompressed TIFFs renamed to .png, very large animated GIFs, or oversized SVGs with embedded base64 payloads.","commonSituations":"User picked a raw camera export, a print-resolution TIFF renamed to a permitted extension, or an animated GIF exported at too high a resolution.","solutions":["Resize or compress the image to under 64 MiB before importing.","For animated GIFs, reduce frame count or dimensions.","For SVGs, remove embedded base64 raster data and reference external assets instead.","If a legitimate pet needs more than 64 MiB, that exceeds the supported format — split it or simplify."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { stat } from 'node:fs/promises'\nconst MAX_BYTES = 64 * 1024 * 1024\n\nconst size = (await stat(pickedPath)).size\nif (size > MAX_BYTES) {\n  notify(`File is ${(size / 1048576).toFixed(1)} MB. Max is 64 MB.`)\n  return\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ipcRenderer.invoke('pet:import')\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('File is too large')) {\n    notify(e.message)\n  } else throw e\n}","preventionTips":["Compress or resize large images before importing.","For animated GIFs, trim frame count and dimensions.","Strip embedded base64 from SVGs."],"tags":["ipc","pet-overlay","filesystem","size-limit","asset-import"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}