{"record":{"id":"eeac6764a108e06d","repo":"paperclipai/paperclip","slug":"queued-comment-not-pending-the-message-is-no-longer","errorCode":"queued_comment_not_pending","errorMessage":"The queued message is no longer pending","messagePattern":"The queued message is no longer pending","errorType":"error_code","errorClass":"QueuedCommentMutationError","httpStatus":null,"severity":"error","filePath":"server/src/modules/wake-queue/application/queued-comment-use-cases.ts","lineNumber":91,"sourceCode":"  revision: string;\n  body: string;\n  now: Date;\n};\n\nexport type EditQueuedCommentResult = {\n  queue: QueuedCommentQueueSnapshot;\n  activityPublication: QueuedCommentActivityPublication;\n};\n\nexport function createEditQueuedComment(deps: { issueLock: QueuedCommentIssueLockWriter }) {\n  return async function editQueuedComment(input: EditQueuedCommentInput): Promise<EditQueuedCommentResult> {\n    return deps.issueLock.withLockedQueue(\n      { issue: input.issue, actor: input.actor, queueId: input.queueId },\n      async (locked, tx) => {\n        requireMutationTarget(locked.queue, input.queueId, input.revision);\n        const entry = locked.queue.entries.find((candidate) => candidate.comment.id === input.commentId);\n        if (!entry) {\n          throw new QueuedCommentMutationError(\"queued_comment_not_pending\", \"The queued message is no longer pending\");\n        }\n        if (!entry.canEdit) {\n          throw new QueuedCommentMutationForbiddenError(\"Only the queued message author can edit it\");\n        }\n\n        const updated = await tx.updateCommentBody({\n          issueId: input.issue.id,\n          commentId: input.commentId,\n          body: input.body,\n          updatedAt: input.now,\n        });\n        if (!updated) {\n          throw new QueuedCommentMutationError(\"queued_comment_not_pending\", \"The queued message is no longer pending\");\n        }\n        await tx.touchIssueUpdatedAt({ issueId: input.issue.id, updatedAt: input.now });\n        await tx.syncCommentReferences(input.commentId);\n        await tx.syncCommentExternalObjectsSafely(input.commentId);\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/server/src/modules/wake-queue/application/queued-comment-use-cases.ts#L73-L109","documentation":"QueuedCommentMutationError with code queued_comment_not_pending, thrown from createEditQueuedComment when the commentId supplied to editQueuedComment cannot be found among the locked queue's pending entries. The queue was locked and the revision matched, but the target comment is no longer part of the pending queue.","triggerScenarios":"Editing a commentId that was already dispatched, discarded, or removed between the client's snapshot and the locked queue read; passing a commentId belonging to a different queue or issue; a typo'd or deleted comment id.","commonSituations":"Stale UI listing a message that was discarded in another tab; client retrying an edit after the message was flushed by the wake scheduler; mixing up comment ids across queue revisions.","solutions":["Re-fetch the queue and confirm the commentId still appears in the pending entries before retrying","Remove the edit affordance for comments no longer pending and refresh the queue view","Verify the commentId and queueId belong to the same issue/queue","If this recurs, check for multiple sessions mutating the same queue and serialize edits through one view"],"exampleFix":"// before\nawait editQueuedComment({ issue, actor, queueId, revision, commentId: staleId, body });\n\n// after\nconst queue = await getQueuedComments({ issue, actor });\nif (!queue.entries.some((e) => e.comment.id === commentId)) {\n  throw new Error('comment no longer pending; refresh queue');\n}\nawait editQueuedComment({ issue, actor, queueId, revision: queue.revision, commentId, body });","handlingStrategy":"validation","validationCode":"const queue = await getQueuedComments({ issue, actor });\nconst entry = queue.entries.find((e) => e.comment.id === commentId);\nif (!entry) throw new Error('comment is no longer pending; refresh the queue');","typeGuard":"function isPendingEntry(queue: { entries: { comment: { id: string } }[] }, commentId: string): boolean {\n  return queue.entries.some((e) => e.comment.id === commentId);\n}","tryCatchPattern":"try {\n  await editQueuedComment(input);\n} catch (e) {\n  if (e?.code === 'queued_comment_not_pending') {\n    await refreshQueue(); // entry gone: show current state\n    return;\n  }\n  throw e;\n}","preventionTips":["Validate the commentId exists in a freshly fetched queue before editing","Refresh the queue view whenever another session may have mutated it","Never reuse commentIds across queue revisions","Check commentId and queueId refer to the same issue"],"tags":["state","concurrency","not-found","queue"],"backgroundTag":"entity-not-found","analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-09-18T08:03:59.046Z","contentChangedAt":"2026-09-18T08:03:59.046Z","schemaVersion":2},"datasetVersion":"2026-09-22T10:30:35.592Z"}