affaan-m/ECC · error
PR title cannot be empty
Error message
PR title cannot be empty
What it means
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.
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.
Example fix
// before
create_draft_pr(&wt, "", "body")?;
// after
let title = subject.trim();
if title.is_empty() { anyhow::bail!("provide a PR title"); }
create_draft_pr(&wt, title, "body")?; Defensive patterns
Strategy: validation
Validate before calling
if title.trim().is_empty() {
return Err(anyhow::anyhow!("PR title required"));
} Type guard
fn has_valid_title(title: &str) -> bool { !title.trim().is_empty() } Try / catch
match create_draft_pr(&wt, title, body) {
Ok(url) => println!("PR: {url}"),
Err(e) if e.to_string().contains("title") => eprintln!("Please provide a PR title"),
Err(e) => return Err(e),
} Prevention
- 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
When it happens
Trigger: Calling create_draft_pr / create_draft_pr_with_options with title="" or a title consisting only of whitespace (spaces, tabs, newlines).
Common situations: 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.
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
- gh pr create failed
- invalid discussion id
- invalid issueNumber: expected positive integer, got
- invalid repo: expected non-empty string, got
- invalid repository
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/67a57583b3d4cb76.
Report an issue: GitHub.
Appendix: 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 8321021c54)