mislav/hub · error

Error: No pull request number given

Error message

Error: No pull request number given

What it means

`gh pull-request checkout` (checkoutPr) requires at least one argument: the pull request number. If no arguments were supplied, it aborts with this usage error before parsing. A second optional argument supplies the new local branch name.

Source

Thrown at commands/pr.go:301

	}

	pulls, err := gh.FetchPullRequests(project, filters, flagPullRequestLimit, func(pr *github.PullRequest) bool {
		return !(onlyMerged && pr.MergedAt.IsZero())
	})
	utils.Check(err)

	colorize := colorizeOutput(args.Flag.HasReceived("--color"), args.Flag.Value("--color"))
	for _, pr := range pulls {
		ui.Print(formatPullRequest(pr, flagPullRequestFormat, colorize))
	}
}

func checkoutPr(command *Command, args *Args) {
	words := args.Words()
	var newBranchName string

	if len(words) == 0 {
		utils.Check(fmt.Errorf("Error: No pull request number given"))
	} else if len(words) > 1 {
		newBranchName = words[1]
	}

	prNumberString := words[0]
	_, err := strconv.Atoi(prNumberString)
	utils.Check(err)

	// Figure out the PR URL
	localRepo, err := github.LocalRepo()
	utils.Check(err)
	baseProject, err := localRepo.MainProject()
	utils.Check(err)
	host, err := github.CurrentConfig().PromptForHost(baseProject.Host)
	utils.Check(err)
	client := github.NewClientWithHost(host)
	pr, err := client.PullRequest(baseProject, prNumberString)
	utils.Check(err)

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Supply the PR number: `git pr checkout 123` or a full PR URL.
  2. If the number comes from a variable, quote it and verify it is non-empty: `git pr checkout "$PR_NUM"`.
  3. Optionally add a branch name as the second argument to control the local branch created.

Example fix

// before
PR_NUM=""; git pr checkout $PR_NUM    // expands to no args
// after
git pr checkout 123
Defensive patterns

Strategy: validation

Validate before calling

if [ -z "$PR_NUM" ]; then echo "usage: git pr checkout <number>"; exit 2; fi
git pr checkout "$PR_NUM"

Prevention

When it happens

Trigger: Running `gh pull-request checkout` (or `git pr checkout`) with zero word arguments — `len(words) == 0` in checkoutPr.

Common situations: Forgetting the PR number/URL; running inside a repo where the command expects `git pr checkout <number>` habit from a different tool; shell scripts dropping an argument due to unquoted/empty variable.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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