{"record":{"id":"979a4d6a4582ca59","repo":"jesseduffield/lazygit","slug":"no-pull-request-found-for-this-branch","errorCode":null,"errorMessage":"No pull request found for this branch","messagePattern":"No pull request found for this branch","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/gui/controllers/branches_controller.go","lineNumber":902,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc (self *BranchesController) branchHasPR(branch *models.Branch) *types.DisabledReason {\n\tif _, ok := self.c.Model().PullRequestsMap[branch.Name]; !ok {\n\t\treturn &types.DisabledReason{Text: self.c.Tr.NoPullRequestForBranch, ShowErrorInPanel: true}\n\t}\n\n\treturn nil\n}\n\nfunc (self *BranchesController) openPRInBrowser(branch *models.Branch) error {\n\tpr, ok := self.c.Model().PullRequestsMap[branch.Name]\n\tif !ok {\n\t\t// Should be guarded against by the DisabledReason check, but be defensive in case\n\t\t// PullRequestsMap was updated concurrently by a background refresh\n\t\treturn errors.New(self.c.Tr.NoPullRequestForBranch)\n\t}\n\n\tself.c.LogAction(self.c.Tr.Actions.OpenPullRequest)\n\n\treturn self.c.OS().OpenLink(pr.Url)\n}\n\nfunc (self *BranchesController) branchesAreReal(selectedBranches []*models.Branch, startIdx int, endIdx int) *types.DisabledReason {\n\tif !lo.EveryBy(selectedBranches, func(branch *models.Branch) bool {\n\t\treturn branch.IsRealBranch()\n\t}) {\n\t\treturn &types.DisabledReason{Text: self.c.Tr.SelectedItemIsNotABranch}\n\t}\n\n\treturn nil\n}\n\nfunc (self *BranchesController) notMergingIntoYourself(branch *models.Branch) *types.DisabledReason {","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/gui/controllers/branches_controller.go#L884-L920","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Refresh lazygit (press 'r' / '@') so PullRequestsMap reloads, then retry","Check that the hosting service integration is configured (e.g. GitHub token in config) so PRs are actually fetched","If no PR exists yet, create one via the create-PR action instead of open-in-browser"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Check the map before opening the browser (the same lookup openPRInBrowser does):\nif _, ok := guiModel.PullRequestsMap[branch.Name]; !ok {\n    // no PR loaded: refresh or create one instead\n    return refreshOrOfferCreate(branch)\n}","typeGuard":null,"tryCatchPattern":"// In Go, treat this as a recoverable miss, not a hard failure:\npr, ok := model.PullRequestsMap[branch.Name]\nif !ok {\n    // DisabledReason normally prevents this; retry after a refresh\n    refreshAndWait()\n    if pr, ok = model.PullRequestsMap[branch.Name]; !ok {\n        return errors.New(\"no pull request found for this branch\")\n    }\n}","preventionTips":["Disable the open-PR action when the map lacks the branch (lazygit already does this via DisabledReason)","Trigger a PullRequestsMap refresh before exposing PR actions","Configure the hosting-service integration so PR data is actually fetched"],"tags":["git","pull-request","model-race","hosting-integration"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}