toeverything/AFFiNE · error · CommentNotFound

comment_not_found

comment_not_found

Error message

Comment not found.

What it means

GraphQL mutation updateComment (resolver.ts:111) loads the comment via service.getComment(input.id); when it returns null the resolver throws CommentNotFound before any permission check or update runs. It means the id does not match any comment row (unknown, deleted, or wrong workspace).

Solutions

  1. Refresh the comment list and retry the edit on an existing comment id.
  2. If the comment was deleted, create a new comment instead of updating the old one.
  3. Guard the UI: disable edit controls for comments missing from the latest listCommentChanges results.
Defensive patterns

Strategy: try-catch

Validate before calling

const comment = await getComment(input.id); // query comments for the doc first
if (!comment) { /* refresh UI, do not send update */ }

Type guard

function isCommentNotFound(e: unknown): boolean {
  return (
    e instanceof GraphQLError &&
    (e.extensions?.code === 'comment_not_found' ||
      e.message === 'Comment not found.')
  );
}

Try / catch

try {
  await updateComment({ id, content });
} catch (e) {
  if (isCommentNotFound(e)) {
    // comment vanished: refetch thread, discard stale editor state, do not retry
  } else throw e;
}

Prevention

When it happens

Trigger: Calling updateComment mutation with a comment id that does not exist or was already deleted - including the race where another user deletes the comment between render and submit.

Common situations: Stale comment panel state after a collaborator deleted the thread; double-submit after an error; id copied from another workspace/environment; comment cleaned up by a moderator.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18). Data as JSON: /api/errors/c310bce2f934325f. Report an issue: GitHub.

Appendix: source

Thrown at packages/backend/server/src/core/comment/resolver.ts:111

      user: {
        id: me.id,
        name: me.name,
        avatarUrl: me.avatarUrl,
      },
      replies: [],
    };
  }

  @Mutation(() => Boolean, {
    description: 'Update a comment content',
  })
  async updateComment(
    @CurrentUser() me: UserType,
    @Args('input') input: CommentUpdateInput
  ) {
    const comment = await this.service.getComment(input.id);
    if (!comment) {
      throw new CommentNotFound();
    }

    await this.assertPermission(me, comment, 'Doc.Comments.Update');

    await this.service.updateComment(input);
    publishCommentChanged(this.realtime, comment.workspaceId, comment.docId);
    return true;
  }

  @Mutation(() => Boolean, {
    description: 'Resolve a comment or not',
  })
  async resolveComment(
    @CurrentUser() me: UserType,
    @Args('input') input: CommentResolveInput
  ) {
    const comment = await this.service.getComment(input.id);
    if (!comment) {

View on GitHub (pinned to b4c8548c09)