BloopAI/vibe-kanban · error · Error
branch_fetch_failed
branch_fetch_failed
Error message
result.error.message
What it means
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).
Source
Thrown at packages/web-core/src/shared/dialogs/command-bar/CreateWorkspaceFromPrDialog.tsx:155
!selectedRemote ||
!selectedPr
) {
throw new Error('Missing required fields');
}
const result = await workspacesApi.createFromPr({
repo_id: selectedRepoId,
pr_number: selectedPrNumber as unknown as bigint,
pr_title: selectedPr.title,
pr_url: selectedPr.url,
head_branch: selectedPr.head_branch,
base_branch: selectedPr.base_branch,
run_setup: runSetup,
remote_name: selectedRemote,
});
if (!result.success) {
switch (result.error?.type) {
case 'branch_fetch_failed':
throw new Error(result.error.message);
case 'auth_failed':
throw new Error(result.error.message);
case 'cli_not_installed':
throw new Error(
t('createWorkspaceFromPr.errors.cliNotInstalled', {
provider: result.error.provider,
})
);
case 'pr_not_found':
throw new Error(t('createWorkspaceFromPr.errors.prNotFound'));
case 'unsupported_provider':
throw new Error(
t('createWorkspaceFromPr.errors.unsupportedProvider')
);
default:
throw new Error(
result.message ||
t('createWorkspaceFromPr.errors.failedToCreateWorkspace')View on GitHub (pinned to 4deb7eca8f)
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
Example fix
// before
throw new Error(result.error.message); // generic surface
// after
catch (e) {
notify.error(`${e.message}. Verify the PR's head branch still exists and the token can read it.`);
refetchPrs();
} Defensive patterns
Strategy: retry
Validate before calling
if (selectedPr.state !== 'open' && selectedPr.headRepo?.deleted) { notify.error('PR head branch no longer exists'); return; } Type guard
function isBranchFetchError(e: CreateFromPrError | undefined): e is { type: 'branch_fetch_failed'; message: string } { return e?.type === 'branch_fetch_failed'; } Try / catch
try {
await createWorkspaceFromPr(fields);
} catch (e) {
notify.error(`${e.message} — check that the PR head branch still exists and your token can read it.`);
refetchPrs();
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- pr_not_found
- Branch '{}' does not exist in repository '{}'
- result.message || 'Failed to attach PR'
- Force push required. The remote branch has diverged.
- Failed to push changes
AI-assisted analysis of BloopAI/vibe-kanban@4deb7eca8f (2026-08-29).
Data as JSON: /api/errors/c314e047feaf1b39.
Report an issue: GitHub.