affaan-m/ECC · warning · anyhow::Error
PR title cannot be empty
Error message
PR title cannot be empty
What it means
create_draft_pr_with_gh trims the supplied title and bails if empty before pushing or invoking gh. An empty PR title is rejected by GitHub anyway, so the library fails fast with a clearer message than the gh CLI would produce.
Source
Thrown at ecc2/src/worktree/mod.rs:542
};
Ok(Some(format!(
"{repo_url}/compare/{}...{}?expand=1",
percent_encode_git_ref(&worktree.base_branch),
percent_encode_git_ref(&worktree.branch)
)))
}
fn create_draft_pr_with_gh(
worktree: &WorktreeInfo,
title: &str,
body: &str,
options: &DraftPrOptions,
gh_bin: &Path,
) -> Result<String> {
let title = title.trim();
if title.is_empty() {
anyhow::bail!("PR title cannot be empty");
}
let base_branch = options
.base_branch
.as_deref()
.map(str::trim)
.filter(|value| !value.is_empty())
.unwrap_or(&worktree.base_branch);
let push = Command::new("git")
.arg("-C")
.arg(&worktree.path)
.args(["push", "-u", "origin", &worktree.branch])
.output()
.context("Failed to push worktree branch before PR creation")?;
if !push.status.success() {
let stderr = String::from_utf8_lossy(&push.stderr);
anyhow::bail!("git push failed: {stderr}");View on GitHub (pinned to 01e15490f0)
Solutions
- Validate the title in the calling layer (`title.trim().is_empty()`) and block submission.
- Default the title to the latest commit subject when the user provides none.
- Ensure the title input has a required-field check in the UI.
Example fix
// before
let url = create_draft_pr(&worktree, title, body)?;
// after
let title = title.trim();
if title.is_empty() {
return Err(anyhow!("PR title is required"));
}
let url = create_draft_pr(&worktree, title, body)?; Defensive patterns
Strategy: validation
Validate before calling
fn ensure_pr_title(title: &str) -> anyhow::Result<&str> {
let t = title.trim();
if t.is_empty() {
anyhow::bail!("PR title is required");
}
Ok(t)
}
let title = ensure_pr_title(title)?;
let url = create_draft_pr(&worktree, title, body)?; Try / catch
match create_draft_pr(&worktree, title, body) {
Ok(url) => Ok(url),
Err(e) if format!("{e}").contains("title cannot be empty") => {
// fall back to latest commit subject, then retry
let fallback = latest_commit_subject(&worktree)?;
create_draft_pr(&worktree, &fallback, body)
}
Err(e) => Err(e),
} Prevention
- Require the title field in the PR form with client-side validation.
- Default the title to the latest commit subject when the user leaves it blank.
- Do not strip template tokens down to nothing in upstream sanitization.
When it happens
Trigger: Calling create_draft_pr / create_draft_pr_with_options with `""`, whitespace-only, or a title that a sanitizer reduced to empty.
Common situations: PR form submitted with no title; title field derived from commit subject that was empty; trimming layer removed template markers leaving nothing.
Related errors
- commit message cannot be empty
- selected hunk is already staged
- selected hunk is not staged
- cannot reset hunks for untracked files
- cannot reset a staged hunk while the file also has unstaged
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/67a57583b3d4cb76.
Report an issue: GitHub.