BloopAI/vibe-kanban · error
result.message || 'Failed to attach PR'
Error message
result.message || 'Failed to attach PR'
What it means
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'.
Source
Thrown at packages/web-core/src/shared/actions/index.ts:922
await ConfirmDialog.show({
title: 'Pull Request Linked',
message: `Linked PR #${result.data.pr_number}${result.data.pr_url ? ` — ${result.data.pr_url}` : ''}`,
confirmText: 'OK',
showCancelButton: false,
variant: 'success',
});
} else if (result.success && !result.data.pr_attached) {
await ConfirmDialog.show({
title: 'No Pull Request Found',
message:
'No open pull request was found matching this branch. Make sure a PR exists for this branch on the remote.',
confirmText: 'OK',
showCancelButton: false,
variant: 'info',
});
} else if (!result.success) {
throw new Error(result.message || 'Failed to attach PR');
}
},
},
GitMerge: {
id: 'git-merge',
label: 'Merge',
icon: GitMergeIcon,
shortcut: 'X M',
requiresTarget: ActionTargetType.GIT,
isVisible: (ctx) => ctx.hasWorkspace && ctx.hasGitRepos,
execute: async (ctx, workspaceId, repoId) => {
// Check for existing conflicts first
const branchStatus = await workspacesApi.getBranchStatus(workspaceId);
const repoStatus = branchStatus?.find((s) => s.repo_id === repoId);
// Check if repo has an open PR - cannot merge directly
const hasOpenPR = repoStatus?.merges?.some(View on GitHub (pinned to 4deb7eca8f)
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).
Example fix
// before
if (!result.success) { throw new Error(result.message || 'Failed to attach PR'); }
// after
if (!result.success) {
logger.warn('attach PR failed', result);
throw new Error(result.message || 'Failed to attach PR');
} Defensive patterns
Strategy: try-catch
Validate before calling
// before attaching: confirm an open PR exists for the branch
const pr = await findOpenPRForBranch(branch);
if (!pr) return showInfoDialog('No open pull request was found matching this branch.'); Type guard
function hasAttachMessage(r: { success: boolean; message?: string }): r is { success: false; message: string } {
return r.success === false && typeof r.message === 'string' && r.message.length > 0;
} Try / catch
try {
await attachPRAction.execute(ctx, workspaceId, repoId);
} catch (e) {
if (e instanceof Error && e.message !== 'Failed to attach PR') showError(e.message);
else showError('Failed to attach PR — check permissions and that the PR is open on the same remote.');
} Prevention
- 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.
When it happens
Trigger: 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'.
Common situations: 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.
Related errors
AI-assisted analysis of BloopAI/vibe-kanban@4deb7eca8f (2026-08-29).
Data as JSON: /api/errors/3766811532a75ec0.
Report an issue: GitHub.