{"record":{"id":"3c5b9b988a0de788","repo":"overleaf/overleaf","slug":"no-docs-for-project-projectid","errorCode":null,"errorMessage":"No docs for project ${projectId}","messagePattern":"No docs for project (.+?)","errorType":"http","errorClass":"NotFoundError","httpStatus":404,"severity":"error","filePath":"services/docstore/app/js/DocManager.js","lineNumber":150,"sourceCode":"    })\n    if (!doc) throw new Errors.NotFoundError()\n    if (!Array.isArray(doc.lines)) throw new Errors.DocWithoutLinesError()\n    return doc.lines.join('\\n')\n  },\n\n  async getAllDeletedDocs(projectId, filter) {\n    return await MongoManager.getProjectsDeletedDocs(projectId, filter)\n  },\n\n  async getAllNonDeletedDocs(projectId, filter) {\n    await DocArchive.unArchiveAllDocs(projectId)\n    const docs = await MongoManager.getProjectsDocs(\n      projectId,\n      { include_deleted: false },\n      filter\n    )\n    if (docs == null) {\n      throw new Errors.NotFoundError(`No docs for project ${projectId}`)\n    }\n    if (filter.ranges) {\n      for (const doc of docs) {\n        RangeManager.fixCommentIds(doc)\n      }\n    }\n    return docs\n  },\n\n  async getAllDocVersions(projectId) {\n    // Do not unarchive all the docs: The version of archived docs is retained in mongo.\n    return await MongoManager.getProjectsDocs(\n      projectId,\n      { include_deleted: false },\n      { _id: true, version: true }\n    )\n  },\n","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/overleaf/overleaf/blob/28ad3b03b71cb4311decdcb55c36b33ec10d72db/services/docstore/app/js/DocManager.js#L132-L168","documentation":"NotFoundError thrown by getAllNonDeletedDocs when getProjectsDocs returns null (not an empty array). null signals the project itself has no docs record/exists-no-docs condition rather than zero non-deleted docs, so it is treated as 'project not found'.","triggerScenarios":"Calling getAllNonDeletedDocs for a projectId with no docs in mongo; project never had docs flushed; wrong projectId; project removed while docs collection emptied.","commonSituations":"Projects created but never written to docstore; fetching docs of a deleted project; id mix-ups between projects in a multi-tenant flow.","solutions":["Catch NotFoundError and return an empty doc list if the project may legitimately have no docs","Verify the projectId exists in the projects collection","Confirm docs were flushed to docstore (web <-> docstore sync) before listing","Correct the projectId at the call site"],"exampleFix":"// before\nconst docs = await docstore.getAllNonDeletedDocs(projectId) // throws\n// after\nlet docs\ntry { docs = await docstore.getAllNonDeletedDocs(projectId) }\ncatch (e) {\n  if (e instanceof Errors.NotFoundError) docs = []\n  else throw e\n}","handlingStrategy":"try-catch","validationCode":"// confirm project has any docs before listing non-deleted\nconst all = await docstore.getAllDocs(projectId).catch(() => [])\nif (all.length === 0) return []","typeGuard":"function isProjectDocsNotFound(e) { return e && e.name === 'NotFoundError' && /No docs for project/.test(e.message) }","tryCatchPattern":"try { return await getAllNonDeletedDocs(projectId) } catch (e) { if (isProjectDocsNotFound(e)) return []; throw e }","preventionTips":["Ensure web flushes new docs to docstore on project creation","Treat null-vs-empty semantics explicitly upstream","Validate projectId before calls","Monitor for projects with zero docs as a sync-health signal"],"tags":["mongodb","not-found","project"],"backgroundTag":"resource-not-found","analyzedSha":"28ad3b03b71cb4311decdcb55c36b33ec10d72db","analyzedAt":"2026-09-03T02:10:22.807Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}