{"record":{"id":"54836b6d40e89b35","repo":"gitbutlerapp/gitbutler","slug":"aborting-due-to-empty-entity","errorCode":null,"errorMessage":"Aborting due to empty {entity}","messagePattern":"Aborting due to empty (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/reword.rs","lineNumber":220,"sourceCode":"            .to_string();\n            if let Some(out) = out.for_human() {\n                writeln!(out, \"Renamed branch '{branch_name}' to '{new_branch_name}'\")?;\n            }\n            return Ok(());\n        }\n    }\n\n    Err(bad_input(\"Branch not found in workspace\")\n        .arg_value(branch_name)\n        .hint(\"You can only reword applied branches\")\n        .into())\n}\n\nfn prepare_provided_message(msg: Option<&str>, entity: &str) -> Option<Result<String>> {\n    msg.map(|msg| {\n        let trimmed = msg.trim();\n        if trimmed.is_empty() {\n            bail!(\"Aborting due to empty {entity}\");\n        }\n        Ok(trimmed.to_string())\n    })\n}\n\npub(crate) fn get_commit_message_from_editor(\n    repo: &gix::Repository,\n    context_lines: u32,\n    commit_details: but_core::diff::CommitDetails,\n    editor_initial_message: String,\n    current_message_for_comparison: &str,\n    show_diff_in_editor: ShowDiffInEditor,\n) -> Result<Option<String>> {\n    let changed_files = get_changed_files_from_commit_details(&commit_details);\n\n    let should_show_diff = show_diff_in_editor.should_show_diff(|| {\n        estimate_diff_blob_size(&commit_details.diff_with_first_parent, repo)\n    })?;","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/reword.rs#L202-L238","documentation":"`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.","triggerScenarios":"Calling `but branch <name> --message \"\"` / `but reword --message \"   \"` (create_branch_for_anonymous_segment, edit_branch_name) with an empty or whitespace-only --message value.","commonSituations":"Shell variable holding the message is unset/empty (`--message \"$MSG\"` with empty MSG); accidental quoting producing an empty argument; scripted renames with blank input.","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"],"exampleFix":"// before\nMSG=\"\"; but reword --message \"$MSG\"  # Aborting due to empty message\n// after\nif [ -n \"$(echo \"$MSG\" | tr -d '[:space:]')\" ]; then but reword --message \"$MSG\"; else echo \"message required\"; fi","handlingStrategy":"validation","validationCode":"const trimmed = (message ?? '').trim();\nif (!trimmed) throw new Error('Message must be non-empty');","typeGuard":"const isNonEmptyMessage = (m) => typeof m === 'string' && m.trim().length > 0;","tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","validation","empty-input"],"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"}