{"record":{"id":"26940c9533c04801","repo":"toeverything/AFFiNE","slug":"doc-canvas-read-failed","errorCode":"DOC_CANVAS_READ_FAILED","errorMessage":"The persisted canvas could not be read.","messagePattern":"The persisted canvas could not be read\\.","errorType":"error_code","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/backend/server/src/plugins/copilot/tools/doc-canvas-read.ts","lineNumber":343,"sourceCode":"  ) => Promise<CanvasReadResult>\n) =>\n  defineTool({\n    description:\n      'Read bounded structure from a persisted document canvas. Use overview first, then a frame, element ids, or region for detail. Use doc_read for Page text and frontend tools for unsynced editor state. Cursors are revision-bound.',\n    inputSchema: z\n      .object({\n        doc_id: z.string().min(1).max(128),\n        target: targetSchema,\n        cursor: z.string().max(2048).optional(),\n        limit: z.number().int().min(1).max(MAX_LIMIT).optional(),\n      })\n      .strict(),\n    execute: async ({ doc_id, target, cursor, limit }) => {\n      try {\n        return await readCanvas(doc_id, target, cursor, limit);\n      } catch {\n        logger.error(`Failed to read canvas ${doc_id}: DOC_CANVAS_READ_FAILED`);\n        return toolError(\n          'Doc Canvas Read Failed',\n          'The persisted canvas could not be read.',\n          {\n            code: 'DOC_CANVAS_READ_FAILED',\n            retryable: false,\n            locator: { doc_id },\n          }\n        );\n      }\n    },\n  });\n","sourceCodeStart":325,"sourceCodeEnd":355,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/plugins/copilot/tools/doc-canvas-read.ts#L325-L355","documentation":"Catch-all inside the doc-canvas read tool's execute: reading the persisted canvas projection from docReader threw, so the failure is logged and converted into a structured 'canvas could not be read' tool error for the model.","triggerScenarios":"Returned as DOC_CANVAS_READ_FAILED when readCanvas throws unexpectedly inside the tool execute wrapper.","commonSituations":"An internal failure occurred loading the persisted canvas projection. Retry later; if persistent, check server logs for DOC_CANVAS_READ_FAILED.","solutions":["Retry reading the persisted canvas; check storage availability.","Verify the document id and 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"}