mislav/hub · error
no open pull requests found for branch '%s'
Error message
no open pull requests found for branch '%s'
What it means
`findCurrentPullRequest` queries GitHub for open pull requests whose head matches the current branch (owner:branch). If the API succeeds but returns zero (or more than one, given the limit) matches, it concludes no open PR exists for the branch and returns this error. It is a lookup-miss, not an API failure.
Source
Thrown at commands/pr.go:403
utils.Check(err)
if headBranch, headProject, err := findPushTarget(currentBranch); err == nil {
headWithOwner = fmt.Sprintf("%s:%s", headProject.Owner, headBranch.ShortName())
} else if headProject, err := deducePushTarget(currentBranch, gh.Host.User); err == nil {
headWithOwner = fmt.Sprintf("%s:%s", headProject.Owner, currentBranch.ShortName())
} else {
headWithOwner = fmt.Sprintf("%s:%s", baseProject.Owner, currentBranch.ShortName())
}
}
filterParams["head"] = headWithOwner
pulls, err := gh.FetchPullRequests(baseProject, filterParams, 1, nil)
if err != nil {
return nil, err
} else if len(pulls) == 1 {
return &pulls[0], nil
} else {
return nil, fmt.Errorf("no open pull requests found for branch '%s'", headWithOwner)
}
}
func branchTrackingInformation(branch *github.Branch) (string, *github.Branch, error) {
branchRemote, err := git.Config(fmt.Sprintf("branch.%s.remote", branch.ShortName()))
if branchRemote == "." {
err = fmt.Errorf("branch is tracking another local branch")
}
if err != nil {
return "", nil, err
}
branchMerge, err := git.Config(fmt.Sprintf("branch.%s.merge", branch.ShortName()))
if err != nil {
return "", nil, err
}
trackingBranch := &github.Branch{
Repo: branch.Repo,
Name: branchMerge,View on GitHub (pinned to 5c547ed804)
Solutions
- Open the PR first (`git pull-request` / `gh pull-request create`) for the current branch.
- Verify the branch's tracking/remote configuration so the head filter resolves to the right owner:branch.
- Check the PR still exists and is open — closed/merged PRs are filtered out.
- View by explicit number instead: `gh pull-request show <number>`.
Example fix
// before git pull-request show // current branch has no open PR // after git pull-request # create the PR first # or view explicitly: git pull-request show 123
Defensive patterns
Strategy: try-catch
Validate before calling
branch := currentBranch()
remote, _ := git.Config(fmt.Sprintf("branch.%s.remote", branch))
if remote == "" {
fmt.Fprintln(os.Stderr, "branch has no upstream; open a PR first")
os.Exit(1)
} Try / catch
pr, err := findCurrentPullRequest(localRepo, gh, baseProject, headFlag)
if err != nil && strings.Contains(err.Error(), "no open pull requests found") {
// fallback: prompt for an explicit PR number
fmt.Fprintln(os.Stderr, "open the PR first or pass a number: gh pull-request show <number>")
} Prevention
- Open a PR for the current branch before running `gh pull-request show` without args.
- Ensure branch tracking (branch.<name>.remote) points at the fork that owns the PR head.
- Remember closed/merged PRs are excluded — check state on the web UI.
- Fall back to an explicit PR number when auto-detection is ambiguous.
When it happens
Trigger: Running `gh pull-request show` with no argument (showPr -> findCurrentPullRequest) on a branch that has no open PR with head `owner:branch`, or where `FetchPullRequests` with the head filter returns an empty result set.
Common situations: Current branch is local-only (PR never opened or already merged/closed); branch pushed from a different fork so the owner:head filter doesn't match; PR exists but with a different head branch name than the local tracking branch.
Related errors
- Aborted: head branch is the same as base ("%s") (use `-h <br
- %s (use `-h <branch>` to specify an explicit pull request he
- the current branch '%s' doesn't seem pushed to a remote
- the branch to compare '%s' is the default branch
- the branch to compare '%s' is the same as --base
AI-assisted analysis of mislav/hub@5c547ed804 (2026-09-01).
Data as JSON: /api/errors/8d9e6af0f0821fe6.
Report an issue: GitHub.