{"record":{"id":"af8096eb5567d7f9","repo":"Stirling-Tools/Stirling-PDF","slug":"file-file-name-not-found-in-storage","errorCode":null,"errorMessage":"File \"${file.name}\" not found in storage","messagePattern":"File \"(.+?)\" not found in storage","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/editor/src/core/utils/downloadUtils.ts","lineNumber":29,"sourceCode":" * @param filename - The filename for the download\n */\nexport function downloadBlob(blob: Blob, filename: string): void {\n  void downloadFile({ data: blob, filename });\n}\n\n/**\n * Downloads a single file from IndexedDB storage\n * @param file - The file object with storage information\n * @throws Error if file cannot be retrieved from storage\n */\nexport async function downloadFileFromStorage(\n  file: StirlingFileStub,\n): Promise<void> {\n  const lookupKey = file.id;\n  const stirlingFile = await fileStorage.getStirlingFile(lookupKey);\n\n  if (!stirlingFile) {\n    throw new Error(`File \"${file.name}\" not found in storage`);\n  }\n\n  await downloadFileWithPolicy({\n    data: stirlingFile,\n    filename: stirlingFile.name,\n    localPath: file.localFilePath,\n    fileId: file.id,\n  });\n}\n\n/**\n * Downloads multiple files as individual downloads\n * @param files - Array of files to download\n */\nexport async function downloadMultipleFiles(\n  files: StirlingFileStub[],\n): Promise<void> {\n  for (const file of files) {","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/Stirling-Tools/Stirling-PDF/blob/9ef20dcab80b85041912f045e17a6aea1d08f969/frontend/editor/src/core/utils/downloadUtils.ts#L11-L47","documentation":"Thrown by downloadFileFromStorage when fileStorage.getStirlingFile(file.id) returns null/undefined — the IndexedDB storage layer could not find a stored file under that id. The file object passed in references storage by id, and the lookup failed, so there is no blob to download. The file's display name is interpolated into the message for user context.","triggerScenarios":"Calling downloadFileFromStorage(file) or downloadMultipleFiles([file]) where file.id does not correspond to any entry in IndexedDB. Happens if the file was evicted by the LRU cache, cleared by the user, stored under a different id, or never persisted (e.g. a generated preview that was not saved to storage).","commonSituations":"The IndexedDB LRU cache evicted a large/old file to make room. The user cleared site data / storage. A file id is stale (the FileContext still references a file that was removed). Private browsing or storage quota limits prevented persistence. A cross-tab race deleted the entry between listing and download.","solutions":["Verify the file still exists in storage before offering the download action (call fileStorage.getStirlingFile and gate the UI).","If the file was evicted, prompt the user to re-upload or re-run the operation that produced it.","Increase the IndexedDB cache size or LRU limit if eviction is frequent.","Ensure generated files are persisted to storage immediately after creation, not just held in memory."],"exampleFix":"// before\nawait downloadFileFromStorage(file); // throws if evicted\n// after\nconst stored = await fileStorage.getStirlingFile(file.id);\nif (!stored) { notify('File no longer available. Please re-run the operation.'); return; }\nawait downloadFileFromStorage(file);","handlingStrategy":"validation","validationCode":"import { fileStorage } from '@app/services/fileStorage';\n\nasync function isFileAvailable(file: StirlingFileStub): Promise<boolean> {\n  return !!(await fileStorage.getStirlingFile(file.id));\n}\n\nif (!(await isFileAvailable(file))) {\n  showUser('This file is no longer in storage. Please re-upload or re-run the operation.');\n  return;\n}","typeGuard":"async function resolveStoredFile(file: StirlingFileStub): Promise<File | null> {\n  return await fileStorage.getStirlingFile(file.id);\n}","tryCatchPattern":"try {\n  await downloadFileFromStorage(file);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('not found in storage')) {\n    showUser(`'${file.name}' is no longer available. It may have been cleared from storage.`);\n  } else { throw e; }\n}","preventionTips":["Check storage availability before enabling the download action in the UI.","Increase the IndexedDB LRU cache size if files are frequently evicted.","Persist generated files to storage immediately after creation.","Handle the 'not found' case gracefully with a re-upload/re-run prompt."],"tags":["download","indexeddb","storage","file-not-found"],"backgroundTag":null,"analyzedSha":"9ef20dcab80b85041912f045e17a6aea1d08f969","analyzedAt":"2026-08-13T22:11:39.827Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}