{"record":{"id":"452f9be46988b39d","repo":"gitbutlerapp/gitbutler","slug":"commit-message-cannot-be-empty","errorCode":null,"errorMessage":"commit message cannot be empty","messagePattern":"commit message cannot be empty","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-action/src/reword.rs","lineNumber":42,"sourceCode":"    meta: &mut impl RefMetadata,\n    db: &mut but_db::DbHandle,\n    context_lines: u32,\n) -> anyhow::Result<(gix::ObjectId, String)> {\n    let changes =\n        but_core::diff::ui::commit_changes_with_line_stats_by_worktree_dir(repo, input.commit_id)?;\n    let diff = changes.try_to_unidiff(repo, context_lines)?.to_string();\n    let message = crate::generate::commit_message(\n        llm,\n        &input.external_summary,\n        &input.external_prompt,\n        &diff,\n    )?;\n\n    // Format the commit message to follow email RFC format (80 char line wrapping)\n    let message = crate::commit_format::format_commit_message(&message);\n\n    if message.is_empty() {\n        bail!(\"commit message cannot be empty\");\n    }\n\n    let editor = Editor::create(ws, meta, repo, db)?;\n    let (rebase, edited_commit_selector) =\n        but_workspace::commit::reword(editor, input.commit_id, message.as_bytes().as_bstr())?;\n    let new_commit_id = rebase.lookup_pick(edited_commit_selector)?;\n    rebase.materialize(Default::default())?;\n\n    Ok((new_commit_id, message))\n}\n","sourceCodeStart":24,"sourceCodeEnd":53,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-action/src/reword.rs#L24-L53","documentation":"but_action::reword::commit bails with \"commit message cannot be empty\" when the (RFC-formatted) commit message passed as input is empty. A reword requires a non-empty message because a commit cannot have an empty message.","triggerScenarios":"Calling but_action reword commit with input whose `message` field is empty or whitespace-only, so format_commit_message yields an empty string and the bail! fires at crates/but-action/src/reword.rs:42.","commonSituations":"An agent/automation sends an empty reword message; a user confirms the message editor without typing anything; trimming strips all content from a placeholder message.","solutions":["Provide a non-empty message in the input before calling commit().","Validate the message at the caller/UI layer and prompt again if empty after trimming.","Skip the reword operation (keep the existing message) when no new message is supplied."],"exampleFix":"// before\ncommit(ws, input_with_empty_message).await?;\n// after\nif input.message.trim().is_empty() {\n    anyhow::bail!(\"provide a commit message\"); // or reuse the old message\n}\ncommit(ws, input).await?;","handlingStrategy":"validation","validationCode":"if !input.message.trim().is_empty() {\n    // safe to call\n}","typeGuard":"fn has_message(m: &str) -> bool { !m.trim().is_empty() }","tryCatchPattern":"match commit(ws, input).await {\n    Err(e) if e.to_string().contains(\"commit message cannot be empty\") => { /* re-prompt or keep old message */ }\n    r => r?,\n}","preventionTips":["Trim and validate commit messages in the UI/agent before submitting.","Never send empty or whitespace-only reword inputs.","Fall back to the existing commit message when the user cancels the editor."],"tags":["rust","validation","commit","empty-message"],"backgroundTag":"empty-required-field","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"}