{"record":{"id":"3fc147e9e6135186","repo":"Mintplex-Labs/anything-llm","slug":"no-docpath-provided-in-request","errorCode":null,"errorMessage":"No docPath provided in request","messagePattern":"No docPath provided in request","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/utils/files/index.js","lineNumber":31,"sourceCode":"    ? path.resolve(__dirname, `../../storage/direct-uploads`)\n    : path.resolve(process.env.STORAGE_DIR, `direct-uploads`);\nconst vectorCachePath =\n  process.env.NODE_ENV === \"development\"\n    ? path.resolve(__dirname, `../../storage/vector-cache`)\n    : path.resolve(process.env.STORAGE_DIR, `vector-cache`);\nconst hotdirPath =\n  process.env.NODE_ENV === \"development\"\n    ? path.resolve(__dirname, `../../../collector/hotdir`)\n    : path.resolve(process.env.STORAGE_DIR, `../../collector/hotdir`);\nconst generatedImagesPath =\n  process.env.NODE_ENV === \"development\"\n    ? path.resolve(__dirname, `../../storage/generated-images`)\n    : path.resolve(process.env.STORAGE_DIR, `generated-images`);\n\n// Should take in a folder that is a subfolder of documents\n// eg: youtube-subject/video-123.json\nasync function fileData(filePath = null) {\n  if (!filePath) throw new Error(\"No docPath provided in request\");\n  const fullFilePath = path.resolve(documentsPath, normalizePath(filePath));\n  if (!fs.existsSync(fullFilePath) || !isWithin(documentsPath, fullFilePath))\n    return null;\n\n  const data = fs.readFileSync(fullFilePath, \"utf8\");\n  return JSON.parse(data);\n}\n\nfunction listFolders() {\n  if (!fs.existsSync(documentsPath)) fs.mkdirSync(documentsPath);\n  const folders = [];\n\n  for (const file of fs.readdirSync(documentsPath)) {\n    if (path.extname(file) === \".md\") continue;\n    const folderPath = path.resolve(documentsPath, file);\n    if (!fs.lstatSync(folderPath).isDirectory()) continue;\n\n    const fileCount = fs","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/files/index.js#L13-L49","documentation":"Thrown by fileData(filePath) in server/utils/files/index.js:30 when filePath is null/undefined/empty. fileData reads a JSON document from the documents directory and is called by document processing, the embedding worker, and document sync jobs.","triggerScenarios":"fileData() called with no argument - e.g. a Document record with null/empty docpath passed into Document methods, embedding-worker processing a file with no path, or sync-watched-documents iterating a record whose docpath is missing.","commonSituations":"Corrupt/partial document record (docpath null); a document deleted from disk but still referenced in the DB; a job enqueued before resolving the file path; race where docpath is not yet persisted.","solutions":["Skip/filter document records with empty docpath before calling fileData (guard at the caller).","Backfill or remove DB rows whose docpath is null.","Ensure the enqueue path always sets docpath before the job runs."],"exampleFix":"// before\nconst data = await fileData(document.docpath);\n// after\nif (!document.docpath) continue;\nconst data = await fileData(document.docpath);","handlingStrategy":"validation","validationCode":"if (!filePath || typeof filePath !== 'string') throw new Error('No docPath provided in request');\n// at call sites:\nif (!doc?.docpath) continue;","typeGuard":null,"tryCatchPattern":"try { const d = await fileData(path); } catch (e) { if (/No docPath provided/.test(e.message)) { log.warn('skipping doc with empty path'); return null; } throw e; }","preventionTips":["Never enqueue a job or read a doc without verifying docpath is a non-empty string.","Add a not-null constraint where possible.","Filter null docpaths at the query level."],"tags":["documents","validation","files","jobs"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}