{"record":{"id":"9dd4c8162a00ac8f","repo":"gitbutlerapp/gitbutler","slug":"no-comment-with-id-id","errorCode":null,"errorMessage":"No comment with id {id}","messagePattern":"No comment with id (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-comments/src/lib.rs","lineNumber":347,"sourceCode":"pub struct Listing {\n    /// The re-anchored, unarchived comments.\n    pub comments: Vec<DiffComment>,\n    /// 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())","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-comments/src/lib.rs#L329-L365","documentation":"update_payload() looks up the comment by its string id inside the comment store and bails when no comment with that id exists. The store is authoritative: any id not found — deleted, archived-removed, or never existed — produces this error.","triggerScenarios":"Calling update_payload with an id that was never created, or an id whose comment was deleted, or a stale id from a previous session/store path.","commonSituations":"A UI keeps a cached comment id after the store was recreated or the workspace changed; a typo'd or truncated id passed from a client; concurrent removal of a comment between listing and editing.","solutions":["Re-fetch the comment list from the store and use a fresh id before updating","Verify the comment id exists via a lookup/get API before calling update_payload","Check that you are pointing at the same comment store file/workspace the id was created in","Handle the not-found case gracefully by prompting the user the comment no longer exists"],"exampleFix":"// before\nupdate_payload(&store, \"cm_123\", text, now)?;\n// after\nif store.list()?.iter().any(|c| c.id == \"cm_123\") {\n    update_payload(&store, \"cm_123\", text, now)?;\n} else {\n    eprintln!(\"Comment cm_123 no longer exists\");\n}","handlingStrategy":"try-catch","validationCode":"fn exists(store: &CommentStore, id: &str) -> bool {\n    store.list().map(|cs| cs.iter().any(|c| c.id == id)).unwrap_or(false)\n}","typeGuard":"let comment = comments.iter().find(|c| c.id == id); if let Some(c) = comment { /* safe */ }","tryCatchPattern":"match update_payload(&store, id, text, now) {\n    Err(e) if e.to_string().contains(\"No comment with id\") => refresh_and_retry_or_warn(),\n    other => other?,\n}","preventionTips":["Always fetch ids from the store immediately before mutation","Re-read the store after any delete/archive operation","Avoid persisting comment ids across store recreations","Treat not-found as a normal outcome in UI flows"],"tags":["comments","lookup","stale-id"],"backgroundTag":"record-not-found","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"}