{"record":{"id":"b0bcac4ed9848f73","repo":"toeverything/AFFiNE","slug":"failed-to-create-doc-for-editing","errorCode":null,"errorMessage":"Failed to create doc for editing","messagePattern":"Failed to create doc for editing","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/frontend/core/src/modules/comment/entities/doc-comment.ts","lineNumber":182,"sourceCode":"  }\n\n  dismissDraftReply(): void {\n    this.pendingReply$.setValue(null);\n  }\n\n  /**\n   * Start editing an existing comment or reply.\n   * This will dismiss any previous editing draft so that only one can exist.\n   */\n  async startEdit(\n    id: CommentId,\n    type: 'comment' | 'reply',\n    snapshot: DocSnapshot,\n    attachments: CommentAttachment[]\n  ): Promise<void> {\n    const doc = await this.snapshotHelper.createStore(snapshot);\n    if (!doc) {\n      throw new Error('Failed to create doc for editing');\n    }\n    this.editingDraft$.setValue({ id, type, doc, attachments });\n  }\n\n  /** Commit current editing draft (if any) */\n  async commitEditing(): Promise<void> {\n    const draft = this.editingDraft$.value;\n    if (!draft) return;\n\n    const snapshot = this.snapshotHelper.getSnapshot(draft.doc);\n    if (!snapshot) {\n      throw new Error('Failed to get snapshot');\n    }\n\n    if (draft.type === 'comment') {\n      await this.updateComment(draft.id, {\n        snapshot,\n        attachments: draft.attachments,","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/frontend/core/src/modules/comment/entities/doc-comment.ts#L164-L200","documentation":"startEdit uses snapshotHelper.createStore(snapshot) to materialize a temp doc for comment editing; a null return means the store could not be created from the snapshot, so editing cannot start and this Error is thrown.","triggerScenarios":"Thrown when startEdit in the comment entity cannot materialize a BlockSuite store from the comment snapshot, i.e. snapshotHelper.createStore returns null. Indicates a corrupted or incompatible comment content snapshot when beginning to edit a comment or reply.","commonSituations":"A user tries to edit an existing comment or reply whose stored snapshot is invalid or from an incompatible schema. Retry after reloading the doc; if persistent, the comment data may be corrupted and need re-creation.","solutions":["Retry; ensure the workspace and doc service are initialized before editing comments.","Check storage/permissions for doc creation."],"exampleFix":null,"handlingStrategy":"type-guard","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"}