overleaf/overleaf · error · NotFoundError

entity not found when downloading doc

Error message

entity not found when downloading doc

What it means

NotFoundError propagated by ProjectLocator.promises.findElement when no doc entity matches the given docId in the project — typically a stale URL, a doc deleted in another tab, or a project/doc id mismatch. The handler logs it as a warning because a missing entity is an expected client-side condition, not a server fault.

Source

Thrown at services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs:28

  try {
    const { element: doc } = await ProjectLocator.promises.findElement({
      project_id: projectId,
      element_id: docId,
      type: 'doc',
    })

    const { lines } = await DocumentUpdaterHandler.promises.getDocument(
      projectId,
      docId,
      -1 // latest version only
    )

    res.setContentDisposition('attachment', { filename: doc.name })
    plainTextResponse(res, lines.join('\n'))
  } catch (err) {
    if (err.name === 'NotFoundError') {
      logger.warn(
        { err, projectId, docId },
        'entity not found when downloading doc'
      )

      return res.sendStatus(404)
    }

    logger.err(
      { err, projectId, docId },
      'error getting document for downloading'
    )

    return res.sendStatus(500)
  }
}

export default {
  getDoc: expressify(getDoc),

View on GitHub (pinned to 28ad3b03b7)

Solutions

  1. Verify the projectId and docId pair actually exists in Mongo before exporting
  2. Check that the doc was not deleted or renamed between the listing request and the download request
  3. Return a 404 to the caller with a localized 'document not found' message
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at services/web/app/src/Features/DocumentUpdater/DocumentUpdaterController.mjs:28 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of overleaf/overleaf@28ad3b03b7 (2026-09-03). Data as JSON: /api/errors/0b4d6ab2c55b38a0. Report an issue: GitHub.