jesseduffield/lazygit · warning

No pull request found for this branch

Error message

No pull request found for this branch

What it means

Thrown by BranchesController.openPRInBrowser when the branch name has no entry in Model().PullRequestsMap. lazygit looks up the PR associated with the branch (from the hosting-service integration, e.g. GitHub/GitLab PR loading) to get its URL; normally the associated keybinding is disabled with a DisabledReason when no PR exists, so this error is the defensive backstop for a race with a concurrent background refresh of the PR list.

Source

Thrown at pkg/gui/controllers/branches_controller.go:902

	}

	return nil
}

func (self *BranchesController) branchHasPR(branch *models.Branch) *types.DisabledReason {
	if _, ok := self.c.Model().PullRequestsMap[branch.Name]; !ok {
		return &types.DisabledReason{Text: self.c.Tr.NoPullRequestForBranch, ShowErrorInPanel: true}
	}

	return nil
}

func (self *BranchesController) openPRInBrowser(branch *models.Branch) error {
	pr, ok := self.c.Model().PullRequestsMap[branch.Name]
	if !ok {
		// Should be guarded against by the DisabledReason check, but be defensive in case
		// PullRequestsMap was updated concurrently by a background refresh
		return errors.New(self.c.Tr.NoPullRequestForBranch)
	}

	self.c.LogAction(self.c.Tr.Actions.OpenPullRequest)

	return self.c.OS().OpenLink(pr.Url)
}

func (self *BranchesController) branchesAreReal(selectedBranches []*models.Branch, startIdx int, endIdx int) *types.DisabledReason {
	if !lo.EveryBy(selectedBranches, func(branch *models.Branch) bool {
		return branch.IsRealBranch()
	}) {
		return &types.DisabledReason{Text: self.c.Tr.SelectedItemIsNotABranch}
	}

	return nil
}

func (self *BranchesController) notMergingIntoYourself(branch *models.Branch) *types.DisabledReason {

View on GitHub (pinned to c477a2959b)

Solutions

  1. Refresh lazygit (press 'r' / '@') so PullRequestsMap reloads, then retry
  2. Check that the hosting service integration is configured (e.g. GitHub token in config) so PRs are actually fetched
  3. If no PR exists yet, create one via the create-PR action instead of open-in-browser
Defensive patterns

Strategy: try-catch

Validate before calling

// Check the map before opening the browser (the same lookup openPRInBrowser does):
if _, ok := guiModel.PullRequestsMap[branch.Name]; !ok {
    // no PR loaded: refresh or create one instead
    return refreshOrOfferCreate(branch)
}

Try / catch

// In Go, treat this as a recoverable miss, not a hard failure:
pr, ok := model.PullRequestsMap[branch.Name]
if !ok {
    // DisabledReason normally prevents this; retry after a refresh
    refreshAndWait()
    if pr, ok = model.PullRequestsMap[branch.Name]; !ok {
        return errors.New("no pull request found for this branch")
    }
}

Prevention

When it happens

Trigger: Invoking 'open PR in browser' on a branch whose PR entry is absent — because no PR exists, the hosting integration is not configured/no token, or the PullRequestsMap refresh removed/has not yet loaded the entry between the disabled-check and the press.

Common situations: Branch with an open PR but lazygit's PR fetching is not running (no hosting service config), stale model right after opening/closing a PR on the website, or pressing the key exactly as a background refresh swaps the map.

Related errors


AI-assisted analysis of jesseduffield/lazygit@c477a2959b (2026-08-15). Data as JSON: /api/errors/979a4d6a4582ca59. Report an issue: GitHub.