mislav/hub · error

Aborting due to empty pull request title

Error message

Aborting due to empty pull request title

What it means

After extracting the title and body from the user's editor/`--file`/commit message, pullRequest validates that a non-empty title was provided. If the title is blank (and no issue number was given to attach the PR to), the PR cannot be created, so it aborts with this error.

Source

Thrown at commands/pull_request.go:315

			}
		}

		workdir, _ := git.WorkdirName()
		if workdir != "" {
			template, _ := github.ReadTemplate(github.PullRequestTemplate, workdir)
			if template != "" {
				message = message + "\n\n\n" + template
			}
		}

		messageBuilder.Message = message
	}

	title, body, err := messageBuilder.Extract()
	utils.Check(err)

	if title == "" && flagPullRequestIssue == "" {
		utils.Check(fmt.Errorf("Aborting due to empty pull request title"))
	}

	if flagPullRequestPush {
		if args.Noop {
			args.Before(fmt.Sprintf("Would push to %s/%s", remote.Name, head), "")
		} else {
			err = git.Spawn("push", "--set-upstream", remote.Name, fmt.Sprintf("HEAD:%s", head))
			utils.Check(err)
		}
	}

	milestoneNumber, err := milestoneValueToNumber(args.Flag.Value("--milestone"), client, baseProject)
	utils.Check(err)

	var pullRequestURL string
	if args.Noop {
		args.Before(fmt.Sprintf("Would request a pull request to %s from %s", fullBase, fullHead), "")
		pullRequestURL = "PULL_REQUEST_URL"

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Provide a title: fill in the first line of the editor message, or pass it via the CLI title flag.
  2. Fix the --file input so the first block (before a blank line) is a non-empty title.
  3. If attaching to an existing issue, pass the issue flag (e.g. `gh pr create -i <issue>`) instead of a title.

Example fix

// before: message file starting with a blank line
""
"Fix login bug..."
// after
"Fix login bug"
"Add validation to the login handler..."
Defensive patterns

Strategy: validation

Validate before calling

title, body, err := messageBuilder.Extract()
if err != nil {
    return err
}
if strings.TrimSpace(title) == "" {
    return errors.New("provide a non-empty PR title (first line of message)")
}

Prevention

When it happens

Trigger: `gh pr create` where `messageBuilder.Extract()` returns title == "" and flagPullRequestIssue == "" — the first block of the edited message was left empty, the `--file` body starts with no title line, or the commit subject is empty.

Common situations: Deleting all text in the interactive editor before saving; a --file template whose first line is blank; creating a PR for an issue without supplying the issue flag; commit messages with only a body.

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


AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01). Data as JSON: /api/errors/d33af772ff2e0704. Report an issue: GitHub.