Mintplex-Labs/anything-llm · error · Error

No docPath provided in request

Error message

No docPath provided in request

What it means

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.

Source

Thrown at server/utils/files/index.js:31

    ? path.resolve(__dirname, `../../storage/direct-uploads`)
    : path.resolve(process.env.STORAGE_DIR, `direct-uploads`);
const vectorCachePath =
  process.env.NODE_ENV === "development"
    ? path.resolve(__dirname, `../../storage/vector-cache`)
    : path.resolve(process.env.STORAGE_DIR, `vector-cache`);
const hotdirPath =
  process.env.NODE_ENV === "development"
    ? path.resolve(__dirname, `../../../collector/hotdir`)
    : path.resolve(process.env.STORAGE_DIR, `../../collector/hotdir`);
const generatedImagesPath =
  process.env.NODE_ENV === "development"
    ? path.resolve(__dirname, `../../storage/generated-images`)
    : path.resolve(process.env.STORAGE_DIR, `generated-images`);

// Should take in a folder that is a subfolder of documents
// eg: youtube-subject/video-123.json
async function fileData(filePath = null) {
  if (!filePath) throw new Error("No docPath provided in request");
  const fullFilePath = path.resolve(documentsPath, normalizePath(filePath));
  if (!fs.existsSync(fullFilePath) || !isWithin(documentsPath, fullFilePath))
    return null;

  const data = fs.readFileSync(fullFilePath, "utf8");
  return JSON.parse(data);
}

function listFolders() {
  if (!fs.existsSync(documentsPath)) fs.mkdirSync(documentsPath);
  const folders = [];

  for (const file of fs.readdirSync(documentsPath)) {
    if (path.extname(file) === ".md") continue;
    const folderPath = path.resolve(documentsPath, file);
    if (!fs.lstatSync(folderPath).isDirectory()) continue;

    const fileCount = fs

View on GitHub (pinned to 526360e320)

Solutions

  1. Skip/filter document records with empty docpath before calling fileData (guard at the caller).
  2. Backfill or remove DB rows whose docpath is null.
  3. Ensure the enqueue path always sets docpath before the job runs.

Example fix

// before
const data = await fileData(document.docpath);
// after
if (!document.docpath) continue;
const data = await fileData(document.docpath);
Defensive patterns

Strategy: validation

Validate before calling

if (!filePath || typeof filePath !== 'string') throw new Error('No docPath provided in request');
// at call sites:
if (!doc?.docpath) continue;

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/3fc147e9e6135186. Report an issue: GitHub.