{"record":{"id":"341c00f66f62bfbe","repo":"toeverything/AFFiNE","slug":"doc-read-failed","errorCode":"DOC_READ_FAILED","errorMessage":"The persisted Page content could not be read.","messagePattern":"The persisted Page content could not be read\\.","errorType":"error_code","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/backend/server/src/plugins/copilot/tools/doc-read.ts","lineNumber":140,"sourceCode":"      .object({\n        doc_id: z\n          .string()\n          .min(1)\n          .max(128)\n          .describe('The persisted document to read'),\n        max_chars: z.number().int().min(1).max(100_000).optional(),\n      })\n      .strict(),\n    execute: async ({ doc_id, max_chars }) => {\n      try {\n        const doc = await getDoc(\n          doc_id,\n          Math.min(max_chars ?? 40_000, 100_000)\n        );\n        return isToolError(doc) ? doc : { ...doc };\n      } catch {\n        logger.error(`Failed to read doc ${doc_id}: DOC_READ_FAILED`);\n        return toolError(\n          'Doc Read Failed',\n          'The persisted Page content could not be read.',\n          { code: 'DOC_READ_FAILED', retryable: false, locator: { doc_id } }\n        );\n      }\n    },\n  });\n};\n","sourceCodeStart":122,"sourceCodeEnd":149,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/plugins/copilot/tools/doc-read.ts#L122-L149","documentation":"Catch-all in the doc_read tool's execute: the underlying getDoc call threw (storage/decode failure), so the error is logged with the doc id and a structured DOC_READ_FAILED tool error is returned to the model.","triggerScenarios":"Returned as DOC_READ_FAILED when getDoc throws unexpectedly while loading persisted page content inside the tool execute wrapper.","commonSituations":"An internal error prevented loading the page content for the copilot. Retry; if it persists, inspect server logs for DOC_READ_FAILED.","solutions":["Retry reading the persisted page content; check storage health.","Verify the document exists in the workspace."],"exampleFix":null,"handlingStrategy":"try-catch","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-14T00:17:10.932Z"}