{"record":{"id":"67a57583b3d4cb76","repo":"affaan-m/ECC","slug":"pr-title-cannot-be-empty","errorCode":null,"errorMessage":"PR title cannot be empty","messagePattern":"PR title cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ecc2/src/worktree/mod.rs","lineNumber":542,"sourceCode":"    };\n\n    Ok(Some(format!(\n        \"{repo_url}/compare/{}...{}?expand=1\",\n        percent_encode_git_ref(&worktree.base_branch),\n        percent_encode_git_ref(&worktree.branch)\n    )))\n}\n\nfn create_draft_pr_with_gh(\n    worktree: &WorktreeInfo,\n    title: &str,\n    body: &str,\n    options: &DraftPrOptions,\n    gh_bin: &Path,\n) -> Result<String> {\n    let title = title.trim();\n    if title.is_empty() {\n        anyhow::bail!(\"PR title cannot be empty\");\n    }\n\n    let base_branch = options\n        .base_branch\n        .as_deref()\n        .map(str::trim)\n        .filter(|value| !value.is_empty())\n        .unwrap_or(&worktree.base_branch);\n\n    let push = Command::new(\"git\")\n        .arg(\"-C\")\n        .arg(&worktree.path)\n        .args([\"push\", \"-u\", \"origin\", &worktree.branch])\n        .output()\n        .context(\"Failed to push worktree branch before PR creation\")?;\n    if !push.status.success() {\n        let stderr = String::from_utf8_lossy(&push.stderr);\n        anyhow::bail!(\"git push failed: {stderr}\");","sourceCodeStart":524,"sourceCodeEnd":560,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/worktree/mod.rs#L524-L560","documentation":"create_draft_pr_with_gh validates that the PR title is non-empty after trimming whitespace before invoking `gh pr create`. An empty title would make `gh` fail with an opaque GitHub API error, so the library rejects it early with a clear message.","triggerScenarios":"Calling create_draft_pr / create_draft_pr_with_options with title=\"\" or a title consisting only of whitespace (spaces, tabs, newlines).","commonSituations":"Auto-generated PR titles built from commit subjects when the branch has no commits (empty subject string); templated workflows where the title field was never filled; passing a variable that defaulted to empty.","solutions":["Supply a non-blank title before calling the API.","If the title derives from the latest commit subject, ensure the branch has a commit with a message.","Trim and validate the title in your own code before the call.","For gh-based callers, note that GitHub also requires a non-empty title, so this check matches upstream behavior."],"exampleFix":"// before\ncreate_draft_pr(&wt, \"\", \"body\")?;\n// after\nlet title = subject.trim();\nif title.is_empty() { anyhow::bail!(\"provide a PR title\"); }\ncreate_draft_pr(&wt, title, \"body\")?;","handlingStrategy":"validation","validationCode":"if title.trim().is_empty() {\n    return Err(anyhow::anyhow!(\"PR title required\"));\n}","typeGuard":"fn has_valid_title(title: &str) -> bool { !title.trim().is_empty() }","tryCatchPattern":"match create_draft_pr(&wt, title, body) {\n    Ok(url) => println!(\"PR: {url}\"),\n    Err(e) if e.to_string().contains(\"title\") => eprintln!(\"Please provide a PR title\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Trim and check titles before every create_draft_pr call","Derive titles from commit subjects but default to a placeholder when empty","Add title validation at the CLI/UX boundary"],"tags":["validation","github","pr"],"backgroundTag":"empty-required-field","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}