gitbutlerapp/gitbutler · error

No comment with id

Error message

No comment with id {id}

What it means

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.

Solutions

  1. Re-fetch the comment list from the store and use a fresh id before updating
  2. Verify the comment id exists via a lookup/get API before calling update_payload
  3. Check that you are pointing at the same comment store file/workspace the id was created in
  4. Handle the not-found case gracefully by prompting the user the comment no longer exists

Example fix

// before
update_payload(&store, "cm_123", text, now)?;
// after
if store.list()?.iter().any(|c| c.id == "cm_123") {
    update_payload(&store, "cm_123", text, now)?;
} else {
    eprintln!("Comment cm_123 no longer exists");
}
Defensive patterns

Strategy: try-catch

Validate before calling

fn exists(store: &CommentStore, id: &str) -> bool {
    store.list().map(|cs| cs.iter().any(|c| c.id == id)).unwrap_or(false)
}

Type guard

let comment = comments.iter().find(|c| c.id == id); if let Some(c) = comment { /* safe */ }

Try / catch

match update_payload(&store, id, text, now) {
    Err(e) if e.to_string().contains("No comment with id") => refresh_and_retry_or_warn(),
    other => other?,
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/9dd4c8162a00ac8f. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-comments/src/lib.rs:347

pub struct Listing {
    /// The re-anchored, unarchived comments.
    pub comments: Vec<DiffComment>,
    /// Whether the listing wrote to the store (persisted drift, auto-archived comments, or
    /// purged old archived rows). Callers that bridge processes can use this to notify other
    /// consumers of the store.
    pub persisted_changes: bool,
}

/// Replace the payload of the unarchived comment with the given `id`.
pub fn update_payload(
    store: &CommentStore,
    id: &str,
    payload: String,
    now_ms: i64,
) -> anyhow::Result<()> {
    store.update(|comments| {
        let Some(comment) = comments.iter_mut().find(|c| c.id == id) else {
            bail!("No comment with id {id}");
        };
        if comment.archived_at_ms.is_some() {
            bail!("Comment {id} is archived and cannot be updated");
        }
        comment.payload = payload;
        comment.updated_at_ms = now_ms;
        Ok(())
    })
}

/// Archive the comment with the given `id`, hiding it from all future listings.
/// Returns `false` if the comment does not exist or was already archived.
pub fn archive_comment(store: &CommentStore, id: &str, now_ms: i64) -> anyhow::Result<bool> {
    store.update(|comments| {
        Ok(
            match comments
                .iter_mut()
                .find(|c| c.id == id && c.archived_at_ms.is_none())

View on GitHub (pinned to 58e5313667)