{"record":{"id":"7c4f480491cfea8a","repo":"gitbutlerapp/gitbutler","slug":"aborting-due-to-empty-pr-title","errorCode":null,"errorMessage":"Aborting due to empty PR title","messagePattern":"Aborting due to empty PR title","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/legacy/forge/review.rs","lineNumber":889,"sourceCode":"            || (!is_selected_branch && selected_branch_message.is_some()),\n        message: is_selected_branch\n            .then_some(selected_branch_message)\n            .flatten(),\n    }\n}\n\n#[derive(Clone, Debug)]\npub struct ForgeReviewMessage {\n    pub title: String,\n    pub body: String,\n}\n\npub fn parse_review_message(content: &str) -> anyhow::Result<ForgeReviewMessage> {\n    let mut lines = content.lines();\n    let title = lines.next().unwrap_or(\"\").trim().to_string();\n\n    if title.is_empty() {\n        anyhow::bail!(\"Aborting due to empty PR title\");\n    }\n\n    // Skip any leading blank lines after the title, then collect the rest as description\n    let body = lines\n        .skip_while(|l| l.trim().is_empty())\n        .collect::<Vec<_>>()\n        .join(\"\\n\")\n        .trim()\n        .to_string();\n\n    Ok(ForgeReviewMessage { title, body })\n}\n\n#[expect(clippy::too_many_arguments)]\nasync fn publish_review_for_branch(\n    ctx: &mut Context,\n    stack_id: Option<StackId>,\n    branch_name: &str,","sourceCodeStart":871,"sourceCodeEnd":907,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/legacy/forge/review.rs#L871-L907","documentation":"`parse_review_message` parses the editor buffer into a PR title + body. The first non-empty trimmed line is the required title; if the content starts with blank lines only (or the file is empty), the title is empty and parsing aborts with this message — mirroring git's behavior of aborting actions on an empty commit message.","triggerScenarios":"Saving an empty file or only whitespace/blank lines in the editor invoked by `get_pr_title_and_body_from_editor`; deleting the title line before saving; piping empty content into `parse_review_message` from any of its parser callers.","commonSituations":"User opens editor, saves without typing a title; editor template customized in a way that leaves the first line blank; scripted use passing empty strings; accidentally `:wq` in vim before typing.","solutions":["Re-run the command and enter a non-empty first line as the title","If the message was lost, check the editor's undo history or recovery files (e.g. vim `~/.vim/undo`), or re-run and rewrite it","Avoid leading blank lines — the title must be on line 1 (leading blanks after the title are fine for the body)","For automation, always include a title as the first line of the passed content"],"exampleFix":"// before\n\"\\n\\nmy description\"        // fails: empty title\n// after\n\"Add feature X\\n\\nmy description\"","handlingStrategy":"validation","validationCode":"let title = content.lines().next().unwrap_or(\"\").trim();\nif title.is_empty() {\n    bail!(\"PR title must be the first line and non-empty\");\n}","typeGuard":null,"tryCatchPattern":"match parse_review_message(&buffer) {\n    Err(e) if e.to_string().contains(\"empty PR title\") => {\n        eprintln!(\"Editor content had no title; aborting without creating PR\");\n    }\n    other => other?,\n}","preventionTips":["Put the title on line 1 of the editor buffer — never leave leading blank lines","Do not customize the editor template in ways that move the title off the first line","In automation, programmatically assert the first line is non-empty before invoking the parser"],"tags":["parse","pr-title","empty"],"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"}