{"record":{"id":"80d66cc8ecc5f506","repo":"stablyai/orca","slug":"unable-to-resolve-branch-base","errorCode":null,"errorMessage":"Unable to resolve branch base","messagePattern":"Unable to resolve branch base","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"mobile/src/source-control/mobile-branch-base-ref.ts","lineNumber":89,"sourceCode":"    if (worktreeBaseRef) {\n      return worktreeBaseRef\n    }\n  }\n\n  if (repoResponse?.ok) {\n    const repo = readRepoSummaries(repoResponse.result).find((candidate) => candidate.id === repoId)\n    const repoBaseRef = repo?.worktreeBaseRef?.trim() || null\n    if (repoBaseRef) {\n      return repoBaseRef\n    }\n  }\n\n  const defaultResponse = await client.sendRequest('repo.baseRefDefault', { repo: `id:${repoId}` })\n  if (!defaultResponse.ok) {\n    if (isMobileGitUnavailable(defaultResponse.error?.code, defaultResponse.error?.message)) {\n      return null\n    }\n    throw new Error(defaultResponse.error?.message || 'Unable to resolve branch base')\n  }\n  return readDefaultBaseRef(defaultResponse.result)\n}\n","sourceCodeStart":71,"sourceCodeEnd":93,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/source-control/mobile-branch-base-ref.ts#L71-L93","documentation":"Thrown by `resolveMobileBranchCompareBaseRef` on its third and final fallback. The function first tries `worktree.show` and `repo.list` (both `.catch(() => null)` tolerant); if neither carries a base ref it calls `repo.baseRefDefault`. When that RPC fails with a code that is NOT a mobile-git-unavailable signal (`forbidden`, `method_not_found`, or the 'not available to mobile clients' message), the error is surfaced. Git-unavailable failures degrade to null instead.","triggerScenarios":"Both `worktree.show` and `repo.list` returned no `worktreeBaseRef`/`baseRef`, AND `repo.baseRefDefault` returns ok:false with a non-transient, non-git-unavailable error code (e.g. `repo_not_found`, `invalid_params`, `internal_error`).","commonSituations":"The repo has no configured default base branch and the host rejects `baseRefDefault`; the `repoId` parsed from the worktree id is stale after a repo rename/move; the host's repo metadata is partially loaded on first pairing; mixed client/host versions where `repo.baseRefDefault` is not yet implemented returns an unexpected code.","solutions":["Verify the repo actually has a default/base branch configured on the host (check repo settings or `git symbolic-ref refs/remotes/origin/HEAD`).","Confirm the `repoId` segment of the mobile worktree id still matches a live repo via `repo.list`.","Update the desktop host so `repo.baseRefDefault` is implemented or returns a stable git-unavailable code for old builds.","If the error is transient (host restarting), reconnect and retry the branch-compare load."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check that at least one source can supply a base ref before depending on it.\nconst hasAnyBaseRefSource =\n  (await client.sendRequest('worktree.show', { worktree: `id:${worktreeId}` }).catch(() => null))?.ok ||\n  (await client.sendRequest('repo.list').catch(() => null))?.ok\nif (!hasAnyBaseRefSource) { /* expect possible throw from baseRefDefault */ }","typeGuard":null,"tryCatchPattern":"let baseRef: string | null\ntry {\n  baseRef = await resolveMobileBranchCompareBaseRef(client, worktreeId)\n} catch (err) {\n  // degrade gracefully — disable compare/rebase rather than crashing the screen\n  baseRef = null\n  reportNonFatal(err)\n}\nif (!baseRef) { setBranchCompareState({ kind: 'idle' }) }","preventionTips":["Treat a null result and a throw differently: null = git-unavailable/degraded, throw = real RPC error.","Configure a default base branch on repos so the final fallback resolves.","Keep `worktree.show`/`repo.list` tolerant (they already `.catch(() => null)`)."],"tags":["rpc","source-control","git","branch","config"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}