{"record":{"id":"3766811532a75ec0","repo":"BloopAI/vibe-kanban","slug":"result-message-failed-to-attach-pr","errorCode":null,"errorMessage":"result.message || 'Failed to attach PR'","messagePattern":"result\\.message \\|\\| 'Failed to attach PR'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/web-core/src/shared/actions/index.ts","lineNumber":922,"sourceCode":"\n        await ConfirmDialog.show({\n          title: 'Pull Request Linked',\n          message: `Linked PR #${result.data.pr_number}${result.data.pr_url ? ` — ${result.data.pr_url}` : ''}`,\n          confirmText: 'OK',\n          showCancelButton: false,\n          variant: 'success',\n        });\n      } else if (result.success && !result.data.pr_attached) {\n        await ConfirmDialog.show({\n          title: 'No Pull Request Found',\n          message:\n            'No open pull request was found matching this branch. Make sure a PR exists for this branch on the remote.',\n          confirmText: 'OK',\n          showCancelButton: false,\n          variant: 'info',\n        });\n      } else if (!result.success) {\n        throw new Error(result.message || 'Failed to attach PR');\n      }\n    },\n  },\n\n  GitMerge: {\n    id: 'git-merge',\n    label: 'Merge',\n    icon: GitMergeIcon,\n    shortcut: 'X M',\n    requiresTarget: ActionTargetType.GIT,\n    isVisible: (ctx) => ctx.hasWorkspace && ctx.hasGitRepos,\n    execute: async (ctx, workspaceId, repoId) => {\n      // Check for existing conflicts first\n      const branchStatus = await workspacesApi.getBranchStatus(workspaceId);\n      const repoStatus = branchStatus?.find((s) => s.repo_id === repoId);\n\n      // Check if repo has an open PR - cannot merge directly\n      const hasOpenPR = repoStatus?.merges?.some(","sourceCodeStart":904,"sourceCodeEnd":940,"githubUrl":"https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/packages/web-core/src/shared/actions/index.ts#L904-L940","documentation":"The GitLinkPR-style attach-PR action calls an API that attempts to attach an existing pull request to the workspace. If the API reports failure (and it is not the specific 'no matching open PR' info case), the action throws with the server's message or the fallback 'Failed to attach PR'.","triggerScenarios":"execute() calls the attach-PR API; result.success is false and the failure is not the 'No open pull request was found matching this branch' info variant — e.g. permission denied, repo mismatch, or API error — so the else-if branch throws result.message || 'Failed to attach PR'.","commonSituations":"PR exists but on a fork/different remote than expected; user lacks permission to attach the PR; backend bug or API version mismatch; transient API failure during PR lookup.","solutions":["Surface result.message — the server message usually names the exact attach failure.","Verify the PR exists, is open, and belongs to the same remote/repo as the workspace branch.","Check the user's permissions on the repo/PR.","Retry if transient; inspect backend logs if result.message is absent (fallback fired)."],"exampleFix":"// before\nif (!result.success) { throw new Error(result.message || 'Failed to attach PR'); }\n// after\nif (!result.success) {\n  logger.warn('attach PR failed', result);\n  throw new Error(result.message || 'Failed to attach PR');\n}","handlingStrategy":"try-catch","validationCode":"// before attaching: confirm an open PR exists for the branch\nconst pr = await findOpenPRForBranch(branch);\nif (!pr) return showInfoDialog('No open pull request was found matching this branch.');","typeGuard":"function hasAttachMessage(r: { success: boolean; message?: string }): r is { success: false; message: string } {\n  return r.success === false && typeof r.message === 'string' && r.message.length > 0;\n}","tryCatchPattern":"try {\n  await attachPRAction.execute(ctx, workspaceId, repoId);\n} catch (e) {\n  if (e instanceof Error && e.message !== 'Failed to attach PR') showError(e.message);\n  else showError('Failed to attach PR — check permissions and that the PR is open on the same remote.');\n}","preventionTips":["Pre-check that an open PR exists for the branch to hit the friendly info path, not the throw.","Verify the PR belongs to the same remote/repo as the workspace branch.","Confirm the user has permission to attach PRs on the target repository.","Log result.message when present to distinguish server causes from the generic fallback."],"tags":["actions","pull-request","api-result","permissions"],"backgroundTag":"pr-attach-failed","analyzedSha":"4deb7eca8f381f7cbc1f9d15515a9ab8f8009053","analyzedAt":"2026-08-29T09:24:13.446Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}