{"record":{"id":"d5fdb729619377c3","repo":"toeverything/AFFiNE","slug":"doc-access-denied-d5fdb7","errorCode":"DOC_ACCESS_DENIED","errorMessage":"Document access denied.","messagePattern":"Document access denied\\.","errorType":"error_code","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/backend/server/src/plugins/copilot/tools/doc-read.ts","lineNumber":69,"sourceCode":"        }\n      );\n    }\n\n    const workspace = await models.workspace.get(options.workspace);\n    if (!workspace) {\n      return workspaceSyncRequiredError();\n    }\n\n    const canAccess = await ac\n      .user(options.user)\n      .workspace(options.workspace)\n      .doc(docId)\n      .can('Doc.Read');\n    if (!canAccess) {\n      logger.warn(\n        `User ${options.user} does not have access to doc ${docId} in workspace ${options.workspace}`\n      );\n      return toolError('Doc Read Failed', 'Document access denied.', {\n        code: 'DOC_ACCESS_DENIED',\n        retryable: false,\n        locator: { doc_id: docId },\n      });\n    }\n\n    const docMeta = await models.doc.getAuthors(options.workspace, docId);\n    if (!docMeta) {\n      return documentSyncPendingError(docId);\n    }\n\n    const content = await docReader.getDocMarkdown(\n      options.workspace,\n      docId,\n      true\n    );\n    if (!content) {\n      return documentSyncPendingError(docId);","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/plugins/copilot/tools/doc-read.ts#L51-L87","documentation":"The copilot Doc Read tool performs an ACL check (Doc.Read) for the user on the target doc; when access is denied it does not throw but returns a structured toolError payload 'Doc Read Failed' with code DOC_ACCESS_DENIED and retryable: false, after logging a warning.","triggerScenarios":"Returned as DOC_ACCESS_DENIED by doc_read when the Doc.Read permission check on the document fails.","commonSituations":"The user cannot read this page due to workspace permissions. Obtain read access from the document owner or admin.","solutions":["Obtain read permission for the document.","Use a document accessible to the user."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}