{"record":{"id":"351688ff5b3f60a7","repo":"mislav/hub","slug":"error-no-pull-request-number-given","errorCode":null,"errorMessage":"Error: No pull request number given","messagePattern":"Error: No pull request number given","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/pr.go","lineNumber":301,"sourceCode":"\t}\n\n\tpulls, err := gh.FetchPullRequests(project, filters, flagPullRequestLimit, func(pr *github.PullRequest) bool {\n\t\treturn !(onlyMerged && pr.MergedAt.IsZero())\n\t})\n\tutils.Check(err)\n\n\tcolorize := colorizeOutput(args.Flag.HasReceived(\"--color\"), args.Flag.Value(\"--color\"))\n\tfor _, pr := range pulls {\n\t\tui.Print(formatPullRequest(pr, flagPullRequestFormat, colorize))\n\t}\n}\n\nfunc checkoutPr(command *Command, args *Args) {\n\twords := args.Words()\n\tvar newBranchName string\n\n\tif len(words) == 0 {\n\t\tutils.Check(fmt.Errorf(\"Error: No pull request number given\"))\n\t} else if len(words) > 1 {\n\t\tnewBranchName = words[1]\n\t}\n\n\tprNumberString := words[0]\n\t_, err := strconv.Atoi(prNumberString)\n\tutils.Check(err)\n\n\t// Figure out the PR URL\n\tlocalRepo, err := github.LocalRepo()\n\tutils.Check(err)\n\tbaseProject, err := localRepo.MainProject()\n\tutils.Check(err)\n\thost, err := github.CurrentConfig().PromptForHost(baseProject.Host)\n\tutils.Check(err)\n\tclient := github.NewClientWithHost(host)\n\tpr, err := client.PullRequest(baseProject, prNumberString)\n\tutils.Check(err)","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/mislav/hub/blob/5c547ed804368763064e51f3990851e267e88edd/commands/pr.go#L283-L319","documentation":"`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.","triggerScenarios":"Running `gh pull-request checkout` (or `git pr checkout`) with zero word arguments — `len(words) == 0` in checkoutPr.","commonSituations":"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.","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."],"exampleFix":"// before\nPR_NUM=\"\"; git pr checkout $PR_NUM    // expands to no args\n// after\ngit pr checkout 123","handlingStrategy":"validation","validationCode":"if [ -z \"$PR_NUM\" ]; then echo \"usage: git pr checkout <number>\"; exit 2; fi\ngit pr checkout \"$PR_NUM\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["pull-request","missing-argument","cli-usage"],"backgroundTag":"missing-required-argument","analyzedSha":"5c547ed804368763064e51f3990851e267e88edd","analyzedAt":"2026-09-01T03:34:15.525Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}