gitbutlerapp/gitbutler · error
Aborting due to empty
Error message
Aborting due to empty {entity} What it means
`prepare_provided_message` validates a user-supplied message for rewording (branch name or commit message). If the provided string is empty or only whitespace after trimming, it bails with "Aborting due to empty {entity}" where entity names what was being renamed/rewritten.
Solutions
- Provide a non-empty message: `--message "new name"`
- Check the shell variable is set before invoking
- Omit --message entirely to be prompted via the editor instead
Example fix
// before MSG=""; but reword --message "$MSG" # Aborting due to empty message // after if [ -n "$(echo "$MSG" | tr -d '[:space:]')" ]; then but reword --message "$MSG"; else echo "message required"; fi
Defensive patterns
Strategy: validation
Validate before calling
const trimmed = (message ?? '').trim();
if (!trimmed) throw new Error('Message must be non-empty'); Type guard
const isNonEmptyMessage = (m) => typeof m === 'string' && m.trim().length > 0;
Prevention
- Validate shell variables before passing them as --message
- Guard against unset variables with ${MSG:?} in shell scripts
- Omit the flag rather than passing an empty value to fall back to the editor prompt
When it happens
Trigger: Calling `but branch <name> --message ""` / `but reword --message " "` (create_branch_for_anonymous_segment, edit_branch_name) with an empty or whitespace-only --message value.
Common situations: Shell variable holding the message is unset/empty (`--message "$MSG"` with empty MSG); accidental quoting producing an empty argument; scripted renames with blank input.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Aborting due to empty branch name
- Cannot create alias ' ': it conflicts with a built-in…
- CLI destination must be absolute
- CLI source ' ' must be an executable file
- CLI source path must be absolute
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/54836b6d40e89b35.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/legacy/reword.rs:220
.to_string();
if let Some(out) = out.for_human() {
writeln!(out, "Renamed branch '{branch_name}' to '{new_branch_name}'")?;
}
return Ok(());
}
}
Err(bad_input("Branch not found in workspace")
.arg_value(branch_name)
.hint("You can only reword applied branches")
.into())
}
fn prepare_provided_message(msg: Option<&str>, entity: &str) -> Option<Result<String>> {
msg.map(|msg| {
let trimmed = msg.trim();
if trimmed.is_empty() {
bail!("Aborting due to empty {entity}");
}
Ok(trimmed.to_string())
})
}
pub(crate) fn get_commit_message_from_editor(
repo: &gix::Repository,
context_lines: u32,
commit_details: but_core::diff::CommitDetails,
editor_initial_message: String,
current_message_for_comparison: &str,
show_diff_in_editor: ShowDiffInEditor,
) -> Result<Option<String>> {
let changed_files = get_changed_files_from_commit_details(&commit_details);
let should_show_diff = show_diff_in_editor.should_show_diff(|| {
estimate_diff_blob_size(&commit_details.diff_with_first_parent, repo)
})?;View on GitHub (pinned to 58e5313667)