{"record":{"id":"48d649a625c8d354","repo":"FlowiseAI/Flowise","slug":"file-filename-not-found-48d649","errorCode":null,"errorMessage":"File ${fileName} not found","messagePattern":"File (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/src/storage/LocalStorageProvider.ts","lineNumber":165,"sourceCode":"            if (fs.existsSync(fallbackPath)) {\n                // Create directory if it doesn't exist\n                const dir = path.dirname(filePath)\n                if (!fs.existsSync(dir)) {\n                    fs.mkdirSync(dir, { recursive: true })\n                }\n\n                // Copy file to correct location with orgId\n                fs.copyFileSync(fallbackPath, filePath)\n\n                // Delete the old file\n                fs.unlinkSync(fallbackPath)\n\n                // Clean up empty directories recursively\n                this.cleanEmptyLocalFolders(path.dirname(fallbackPath))\n\n                return fs.createReadStream(filePath)\n            } else {\n                throw new Error(`File ${fileName} not found`)\n            }\n        }\n    }\n\n    async getFilesListFromStorage(...paths: string[]): Promise<FileInfo[]> {\n        const directory = this.buildPath(...paths)\n        return this.getFilePaths(directory)\n    }\n\n    private getFilePaths(dir: string): FileInfo[] {\n        let results: FileInfo[] = []\n\n        const readDirectory = (directory: string) => {\n            try {\n                if (!fs.existsSync(directory)) {\n                    console.warn(`Directory does not exist: ${directory}`)\n                    return\n                }","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/src/storage/LocalStorageProvider.ts#L147-L183","documentation":"Thrown by LocalStorageProvider.streamStorageFile when the file does not exist at the primary path (orgId/chatflowId/chatId/name) and also does not exist at the legacy fallback path (chatflowId/chatId/name). It signals a genuine on-disk miss after the migration fallback was attempted.","triggerScenarios":"Requesting a file that was never written, was deleted, or whose fallback migration already moved it. The throw is at LocalStorageProvider.ts:165 in the final else branch.","commonSituations":"Stale attachment references; files removed by cleanup; race between upload and read; wrong orgId scoping.","solutions":["Verify the file exists on disk under the expected path layout before serving.","Return 404 to the client and avoid leaking internal paths.","Re-upload the file or correct the orgId/chatflowId/chatId used in the request."],"exampleFix":"// before\nconst stream = await provider.streamStorageFile(chatflowId, chatId, fileName, orgId)\n// after\ntry {\n  const stream = await provider.streamStorageFile(chatflowId, chatId, fileName, orgId)\n} catch (e) {\n  if (/not found/i.test(e.message)) return res.status(404).send('file not found')\n  throw e\n}","handlingStrategy":"try-catch","validationCode":"function localFileExists(p: string): boolean {\n  try { return fs.existsSync(p) } catch { return false }\n}\n// existence may change between check and read; pair with try-catch","typeGuard":"function isLocalNotFound(err: unknown): boolean {\n  return err instanceof Error && /not found/i.test(err.message)\n}","tryCatchPattern":"try {\n  const stream = await provider.streamStorageFile(chatflowId, chatId, fileName, orgId)\n} catch (e) {\n  if (e instanceof Error && /not found/i.test(e.message)) return res.status(404).send('file not found')\n  throw e\n}","preventionTips":["Return 404 for missing local files.","Verify the expected path layout before serving.","Avoid retrying a confirmed-missing file."],"tags":["storage","local","file-not-found"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}