{"record":{"id":"3ff44b36d737f93a","repo":"gitbutlerapp/gitbutler","slug":"comment-id-is-archived-and-cannot-be-updated","errorCode":null,"errorMessage":"Comment {id} is archived and cannot be updated","messagePattern":"Comment (.+?) is archived and cannot be updated","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-comments/src/lib.rs","lineNumber":350,"sourceCode":"    /// Whether the listing wrote to the store (persisted drift, auto-archived comments, or\n    /// purged old archived rows). Callers that bridge processes can use this to notify other\n    /// consumers of the store.\n    pub persisted_changes: bool,\n}\n\n/// Replace the payload of the unarchived comment with the given `id`.\npub fn update_payload(\n    store: &CommentStore,\n    id: &str,\n    payload: String,\n    now_ms: i64,\n) -> anyhow::Result<()> {\n    store.update(|comments| {\n        let Some(comment) = comments.iter_mut().find(|c| c.id == id) else {\n            bail!(\"No comment with id {id}\");\n        };\n        if comment.archived_at_ms.is_some() {\n            bail!(\"Comment {id} is archived and cannot be updated\");\n        }\n        comment.payload = payload;\n        comment.updated_at_ms = now_ms;\n        Ok(())\n    })\n}\n\n/// Archive the comment with the given `id`, hiding it from all future listings.\n/// Returns `false` if the comment does not exist or was already archived.\npub fn archive_comment(store: &CommentStore, id: &str, now_ms: i64) -> anyhow::Result<bool> {\n    store.update(|comments| {\n        Ok(\n            match comments\n                .iter_mut()\n                .find(|c| c.id == id && c.archived_at_ms.is_none())\n            {\n                Some(comment) => {\n                    comment.archived_at_ms = Some(now_ms);","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-comments/src/lib.rs#L332-L368","documentation":"update_payload() refuses to edit a comment that has been archived (archived_at_ms is set). Archived comments are treated as immutable history, so any payload update is rejected even though the id still resolves.","triggerScenarios":"Calling update_payload on a comment whose archived_at_ms field is Some, typically after the user archived the comment in the UI or the system auto-archived resolved threads.","commonSituations":"Two windows open on the same workspace: one archives the comment, the other still has the editor open and tries to save; automation updating comments without checking archive state; retry of a queued edit after archival.","solutions":["Check comment.archived_at_ms.is_none() before attempting the update","Unarchive the comment first if your workflow allows it, then update","Discard the pending edit and inform the user the comment was archived","Re-sync UI state on archive events so stale editors cannot save"],"exampleFix":"// before\nupdate_payload(&store, id, text, now)?;\n// after\nlet c = store.get(id)?;\nif c.archived_at_ms.is_none() {\n    update_payload(&store, id, text, now)?;\n} else {\n    eprintln!(\"Comment is archived; not updating\");\n}","handlingStrategy":"type-guard","validationCode":"fn editable(c: &Comment) -> bool { c.archived_at_ms.is_none() }","typeGuard":"if comment.archived_at_ms.is_none() { /* safe to update */ }","tryCatchPattern":"match update_payload(&store, id, text, now) {\n    Err(e) if e.to_string().contains(\"archived\") => discard_edit_and_notify(),\n    other => other?,\n}","preventionTips":["Check archived state before opening an editor for a comment","Listen for archive events and disable stale editors","Avoid blind retries of failed updates","Keep archive/unarchive flows explicit in the UI"],"tags":["comments","archived","immutable-state"],"backgroundTag":"invalid-state-transition","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}