{"record":{"id":"8fab735e0190215e","repo":"stablyai/orca","slug":"could-not-refresh-base-ref-basebranch-from","errorCode":null,"errorMessage":"Could not refresh base ref \"${baseBranch}\" from \"${remoteTrackingBase.remote}\". Check your network and try again.","messagePattern":"Could not refresh base ref \"(.+?)\" from \"(.+?)\"\\. Check your network and try again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktree-remote.ts","lineNumber":1658,"sourceCode":"          presetDirectories.length === sparseDirectories.length &&\n          sparseDirectories.every((entry) => presetSet.has(entry))\n        sparsePresetId = directoriesMatch ? preset.id : undefined\n      } catch {\n        // Why: corrupt preset data should not block creation or falsely label the new worktree.\n      }\n    }\n  }\n\n  // Why: addWorktree/setup probes run inside the new path; older relays need that root registered before accepting git/fs ops there.\n  await registerRequiredSshWorktreeCreateRoots(repo.connectionId!, [remotePath])\n\n  if (remoteTrackingBase) {\n    try {\n      await refreshRemoteTrackingBaseForWorktreeCreate(provider, repo, remoteTrackingBase)\n    } catch {\n      // Why: a refresh failure shouldn't block create if a usable (stale) local base ref exists; probe after registerRoot and hard-fail only when none does.\n      if (!(await hasRemoteTrackingRefSsh(provider, repo.path, remoteTrackingBase.ref))) {\n        throw new Error(\n          `Could not refresh base ref \"${baseBranch}\" from \"${remoteTrackingBase.remote}\". Check your network and try again.`\n        )\n      }\n    }\n  } else if (!(await hasRemoteWorktreeBaseRef(provider, repo.path, baseBranch))) {\n    // Why: non-remote-tracking bases keep the legacy best-effort fetch; verified PR/MR SHA bases already have the object, so a broad fetch is wasted.\n    try {\n      await fetchRemoteForWorktreeCreate(provider, repo, 'origin')\n    } catch {\n      /* best-effort */\n    }\n  }\n\n  const localBaseRefRefresh =\n    settings.refreshLocalBaseRefOnWorktreeCreate && !checkoutExistingBranch && remoteTrackingBase\n      ? await refreshLocalBaseRefForRemoteWorktreeCreate(provider, repo.path, remoteTrackingBase)\n      : undefined\n  const localBaseRefUpdateSuggestion =","sourceCodeStart":1640,"sourceCodeEnd":1676,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktree-remote.ts#L1640-L1676","documentation":"Remote create: refreshing the remote-tracking base ref failed AND no usable stale local copy of that ref exists. refreshRemoteTrackingBaseForWorktreeCreate threw, and the follow-up hasRemoteTrackingRefSsh also reported the ref absent. The code blocks create only when BOTH conditions hold — a stale-but-present ref would let git worktree add proceed. The message points at network because the refresh is a fetch.","triggerScenarios":"Remote create with a remoteTrackingBase; the fetch/refresh threw (network down, SSH unreachable, auth failure) and hasRemoteTrackingRefSsh(provider, repo.path, remoteTrackingBase.ref) returned false. Reached at worktree-remote.ts:1658.","commonSituations":"VPN/network outage to the SSH host; SSH key revoked or agent not forwarded; remote deleted the branch since last clone (so no stale ref either); relay connection dropped mid-fetch; first-ever create on a host with no local refs cached.","solutions":["Restore network/SSH connectivity to the host and retry (the refresh is retried on each create).","Confirm the base branch still exists on the remote (git ls-remote).","Pass an explicit baseBranch that is already cached locally, or pick a different base, so the create can proceed from the stale ref.","Re-authenticate the SSH connection if the fetch failed with an auth error."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm connectivity + ref presence before create\nconst reachable = await pingSshHost(connectionId)\nconst hasRef = await hasRemoteTrackingRefSsh(provider, repo.path, remoteTrackingBase.ref)\nif (!reachable || !hasRef) {\n  return { ok: false, error: 'Base ref unavailable and host unreachable. Check network and retry.' }\n}","typeGuard":null,"tryCatchPattern":"catch (err) {\n  if (err instanceof Error && err.message.startsWith('Could not refresh base ref')) {\n    // transient network: retry once after reconnect\n    await reconnectSsh(connectionId)\n    return retryCreate()\n  }\n  throw err\n}","preventionTips":["Keep the SSH connection healthy; reconnect before a create if it's been idle.","Prefetch and cache the base ref so a refresh failure can fall back to the local copy.","Confirm the base branch still exists on the remote before creating."],"tags":["worktree-create","base-ref","network","ssh","git-fetch"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}