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
- Supply the PR number: `git pr checkout 123` or a full PR URL.
- If the number comes from a variable, quote it and verify it is non-empty: `git pr checkout "$PR_NUM"`.
- 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
- Always include the PR number argument in scripts and quotes.
- Validate PR number variables are non-empty before invoking.
- Optionally pass a second arg to name the local branch explicitly.
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
- This gist contains multiple files, you must specify one: %
- no such file in gist
- error: no milestone found with name '%s'
- Error: that fork is not available anymore
- invalid pull request number: '%s'
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/351688ff5b3f60a7.
Report an issue: GitHub.