{"record":{"id":"c314e047feaf1b39","repo":"BloopAI/vibe-kanban","slug":"branch-fetch-failed","errorCode":"branch_fetch_failed","errorMessage":"result.error.message","messagePattern":"result\\.error\\.message","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/web-core/src/shared/dialogs/command-bar/CreateWorkspaceFromPrDialog.tsx","lineNumber":155,"sourceCode":"          !selectedRemote ||\n          !selectedPr\n        ) {\n          throw new Error('Missing required fields');\n        }\n        const result = await workspacesApi.createFromPr({\n          repo_id: selectedRepoId,\n          pr_number: selectedPrNumber as unknown as bigint,\n          pr_title: selectedPr.title,\n          pr_url: selectedPr.url,\n          head_branch: selectedPr.head_branch,\n          base_branch: selectedPr.base_branch,\n          run_setup: runSetup,\n          remote_name: selectedRemote,\n        });\n        if (!result.success) {\n          switch (result.error?.type) {\n            case 'branch_fetch_failed':\n              throw new Error(result.error.message);\n            case 'auth_failed':\n              throw new Error(result.error.message);\n            case 'cli_not_installed':\n              throw new Error(\n                t('createWorkspaceFromPr.errors.cliNotInstalled', {\n                  provider: result.error.provider,\n                })\n              );\n            case 'pr_not_found':\n              throw new Error(t('createWorkspaceFromPr.errors.prNotFound'));\n            case 'unsupported_provider':\n              throw new Error(\n                t('createWorkspaceFromPr.errors.unsupportedProvider')\n              );\n            default:\n              throw new Error(\n                result.message ||\n                  t('createWorkspaceFromPr.errors.failedToCreateWorkspace')","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/packages/web-core/src/shared/dialogs/command-bar/CreateWorkspaceFromPrDialog.tsx#L137-L173","documentation":"After createFromPr returns unsuccessfully with error.type 'branch_fetch_failed', the dialog throws Error(result.error.message), surfacing the backend's explanation that the branch could not be fetched from the remote repository (auth to the git host succeeded enough to identify the failure, but the branch ref was not retrievable).","triggerScenarios":"result.success === false and result.error.type === 'branch_fetch_failed': the PR head branch was deleted after the PR was created, the branch lives on a fork the token cannot read, the repo was renamed/transferred, or the PR ref (e.g. refs/pull/N/head) is unavailable on the configured remote.","commonSituations":"Merged/closed PR whose head branch was auto-deleted; creating a workspace from a PR in a fork where the installation token lacks fork access; provider outage making refs unreachable; stale cached PR data pointing at a renamed repo.","solutions":["Confirm the PR's head branch still exists on the source repo (closed PRs with deleted branches cannot be used)","Re-authenticate the git provider so the token has access to the fork/branch","Refresh the PR list to clear stale repo/PR references, then retry","If using a fork PR, grant the app/token access to the fork repository","Check the provider's status page if refs fail across many PRs"],"exampleFix":"// before\nthrow new Error(result.error.message); // generic surface\n// after\ncatch (e) {\n  notify.error(`${e.message}. Verify the PR's head branch still exists and the token can read it.`);\n  refetchPrs();\n}","handlingStrategy":"retry","validationCode":"if (selectedPr.state !== 'open' && selectedPr.headRepo?.deleted) { notify.error('PR head branch no longer exists'); return; }","typeGuard":"function isBranchFetchError(e: CreateFromPrError | undefined): e is { type: 'branch_fetch_failed'; message: string } { return e?.type === 'branch_fetch_failed'; }","tryCatchPattern":"try {\n  await createWorkspaceFromPr(fields);\n} catch (e) {\n  notify.error(`${e.message} — check that the PR head branch still exists and your token can read it.`);\n  refetchPrs();\n}","preventionTips":["Refresh PR data before creating workspaces from old/closed PRs","Ensure the git token has fork access for cross-repo PRs","Handle result.success === false explicitly per error.type instead of a blanket catch","Re-authenticate the provider if branch fetches fail consistently"],"tags":["git","branch","pull-request","remote"],"backgroundTag":"git-branch-fetch-failed","analyzedSha":"4deb7eca8f381f7cbc1f9d15515a9ab8f8009053","analyzedAt":"2026-08-29T09:24:13.446Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}