mislav/hub · error

invalid pull request number: '%s'

Error message

invalid pull request number: '%s'

What it means

`showPr` expects its first argument, when present, to be a pull request number. It parses the word with `strconv.Atoi`; on failure it raises this error instead of treating it as a URL or branch. Only bare numeric PR identifiers are accepted here.

Source

Thrown at commands/pr.go:347

	utils.Check(err)

	baseProject, err := localRepo.MainProject()
	utils.Check(err)

	host, err := github.CurrentConfig().PromptForHost(baseProject.Host)
	utils.Check(err)
	gh := github.NewClientWithHost(host)

	words := args.Words()
	openURL := ""
	prNumber := 0
	var pr *github.PullRequest

	if len(words) > 0 {
		if prNumber, err = strconv.Atoi(words[0]); err == nil {
			openURL = baseProject.WebURL("", "", fmt.Sprintf("pull/%d", prNumber))
		} else {
			utils.Check(fmt.Errorf("invalid pull request number: '%s'", words[0]))
		}
	} else {
		pr, err = findCurrentPullRequest(localRepo, gh, baseProject, args.Flag.Value("--head"))
		utils.Check(err)
		openURL = pr.HTMLURL
	}

	args.NoForward()
	if format := args.Flag.Value("--format"); format != "" {
		if pr == nil {
			pr, err = gh.PullRequest(baseProject, strconv.Itoa(prNumber))
			utils.Check(err)
		}
		colorize := colorizeOutput(args.Flag.HasReceived("--color"), args.Flag.Value("--color"))
		ui.Println(formatPullRequest(*pr, format, colorize))
		return
	}

View on GitHub (pinned to 5c547ed804)

Solutions

  1. Pass the bare numeric PR number: `gh pull-request show 123`.
  2. If you meant to view by URL, strip to the number or use the URL form supported by the command.
  3. Omit the argument entirely to auto-detect the current branch's PR (findCurrentPullRequest path).

Example fix

// before
gh pull-request show feature/foo   // non-numeric
// after
gh pull-request show 123
Defensive patterns

Strategy: validation

Validate before calling

arg := os.Args[len(os.Args)-1]
if _, err := strconv.Atoi(arg); err != nil {
    fmt.Fprintf(os.Stderr, "%q is not a PR number; pass a bare numeric id or omit the arg to auto-detect\n", arg)
    os.Exit(2)
}

Type guard

func isPRNumber(s string) bool {
    _, err := strconv.Atoi(s)
    return err == nil
}

Prevention

When it happens

Trigger: Running `gh pull-request show <arg>` where `<arg>` is non-numeric — e.g. a branch name, a partial URL, or a typo like "12a" — in `showPr`.

Common situations: Passing a branch name expecting branch resolution (not supported in this arg position); pasting a PR URL where a bare number is required; typos or copied text with whitespace/characters.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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