{"record":{"id":"111c92aa78b5b8e8","repo":"gitbutlerapp/gitbutler","slug":"valid-commit-that-can-be-parsed-todo-allow-it-t","errorCode":null,"errorMessage":"valid commit that can be parsed: TODO - allow it to return errors?","messagePattern":"valid commit that can be parsed: TODO - allow it to return errors\\?","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/gitbutler-commit/src/commit_ext.rs","lineNumber":31,"sourceCode":"    /// Obtain the commit-message as bytes, but without assuming any encoding.\n    fn message_bstr(&self) -> &BStr;\n}\n\nimpl CommitExt for gix::Commit<'_> {\n    fn change_id(&self) -> Option<ChangeId> {\n        let commit = self.decode().ok()?;\n        Headers::try_from_commit_headers(|| commit.extra_headers())?.change_id\n    }\n\n    fn is_conflicted(&self) -> bool {\n        but_core::Commit::try_from(self.clone()).is_ok_and(|commit| commit.is_conflicted())\n    }\n}\n\nimpl CommitMessageBstr for gix::Commit<'_> {\n    fn message_bstr(&self) -> &BStr {\n        self.message_raw()\n            .expect(\"valid commit that can be parsed: TODO - allow it to return errors?\")\n    }\n}\n","sourceCodeStart":13,"sourceCodeEnd":34,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-commit/src/commit_ext.rs#L13-L34","documentation":"The CommitMessageBstr impl for gix::Commit delegates message_bstr() to message_raw(), which returns a Result, and unwraps it with expect. The assumption is that a loaded commit object can always have its message decoded; if the underlying object read/decode fails, this panics. The TODO acknowledges it should return errors instead.","triggerScenarios":"Calling message_bstr() (e.g. via commit_title_to_merge_conflict_label when generating a merge-conflict label from a commit title) on a commit whose message_raw() fails — corrupt/missing object data or undecodable bytes.","commonSituations":"Repository object corruption or truncation; reading commits from an object database that fails lazily; labels for merge conflicts built from unusual commits.","solutions":["Change the trait method or call site to propagate the error (make message_bstr fallible or add a try_ variant)","Fall back to an empty/default label when the message cannot be read","Run `git fsck` on the repository to find and repair corrupt objects"],"exampleFix":"// before\nfn message_bstr(&self) -> &BStr {\n    self.message_raw()\n        .expect(\"valid commit that can be parsed: TODO - allow it to return errors?\")\n}\n// after\nfn message_bstr(&self) -> anyhow::Result<&BStr> {\n    Ok(self.message_raw()?)\n}","handlingStrategy":"fallback","validationCode":"// Check the object is readable before extracting the title:\nlet label = commit.message_raw().ok().map(commit_title).unwrap_or_default();","typeGuard":"fn has_readable_message(commit: &gix::Commit) -> bool {\n    commit.message_raw().is_ok()\n}","tryCatchPattern":"// At call sites like commit_title_to_merge_conflict_label, fall back:\nlet title = commit.message_raw().map_or_else(\n    |_| \"(unreadable commit message)\".to_string(),\n    |m| title_from_message(m),\n);","preventionTips":["Run `git fsck` when commit objects fail to decode","Avoid panicking helpers on lazy object reads; propagate errors through the label builder","Clone/fetch fresh copies of repositories whose objects appear corrupt"],"tags":["rust","git","panic","commit","object-corruption"],"backgroundTag":"internal-invariant-violation","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"}