{"record":{"id":"1e024ad81ca202e4","repo":"overleaf/overleaf","slug":"not-found-entity-not-found-when-downloading-doc-r","errorCode":null,"errorMessage":"Not Found (entity not found when downloading doc res.sendStatus(404))","messagePattern":"Not Found \\(entity not found when downloading doc res\\.sendStatus\\(404\\)\\)","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs","lineNumber":33,"sourceCode":"      type: 'doc',\n    })\n\n    const { lines } = await DocumentUpdaterHandler.promises.getDocument(\n      projectId,\n      docId,\n      -1 // latest version only\n    )\n\n    res.setContentDisposition('attachment', { filename: doc.name })\n    plainTextResponse(res, lines.join('\\n'))\n  } catch (err) {\n    if (err.name === 'NotFoundError') {\n      logger.warn(\n        { err, projectId, docId },\n        'entity not found when downloading doc'\n      )\n\n      return res.sendStatus(404)\n    }\n\n    logger.err(\n      { err, projectId, docId },\n      'error getting document for downloading'\n    )\n\n    return res.sendStatus(500)\n  }\n}\n\nexport default {\n  getDoc: expressify(getDoc),\n}\n","sourceCodeStart":15,"sourceCodeEnd":48,"githubUrl":"https://github.com/overleaf/overleaf/blob/28ad3b03b71cb4311decdcb55c36b33ec10d72db/services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs#L15-L48","documentation":"Sent by getDoc when downloading a document and the error thrown while fetching project/doc metadata or the doc content from the document updater has name 'NotFoundError'. This is a sentinel-name guard: the project or doc id supplied in the URL does not exist (or is not visible), so the request is answered with 404 and a warning log.","triggerScenarios":"Thrown at services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs:33 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the project_id and doc_id in the URL are correct and belong together","Check that the doc has not been deleted or renamed in the project","If the doc lives in a different project, use the correct project-scoped URL","No server action needed if the client simply referenced a stale doc id"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"28ad3b03b71cb4311decdcb55c36b33ec10d72db","analyzedAt":"2026-09-03T02:10:22.807Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T07:17:11.731Z"}