stablyai/orca · error · Error

Unable to resolve branch base

Error message

Unable to resolve branch base

What it means

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.

Source

Thrown at mobile/src/source-control/mobile-branch-base-ref.ts:89

    if (worktreeBaseRef) {
      return worktreeBaseRef
    }
  }

  if (repoResponse?.ok) {
    const repo = readRepoSummaries(repoResponse.result).find((candidate) => candidate.id === repoId)
    const repoBaseRef = repo?.worktreeBaseRef?.trim() || null
    if (repoBaseRef) {
      return repoBaseRef
    }
  }

  const defaultResponse = await client.sendRequest('repo.baseRefDefault', { repo: `id:${repoId}` })
  if (!defaultResponse.ok) {
    if (isMobileGitUnavailable(defaultResponse.error?.code, defaultResponse.error?.message)) {
      return null
    }
    throw new Error(defaultResponse.error?.message || 'Unable to resolve branch base')
  }
  return readDefaultBaseRef(defaultResponse.result)
}

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Verify the repo actually has a default/base branch configured on the host (check repo settings or `git symbolic-ref refs/remotes/origin/HEAD`).
  2. Confirm the `repoId` segment of the mobile worktree id still matches a live repo via `repo.list`.
  3. Update the desktop host so `repo.baseRefDefault` is implemented or returns a stable git-unavailable code for old builds.
  4. If the error is transient (host restarting), reconnect and retry the branch-compare load.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check that at least one source can supply a base ref before depending on it.
const hasAnyBaseRefSource =
  (await client.sendRequest('worktree.show', { worktree: `id:${worktreeId}` }).catch(() => null))?.ok ||
  (await client.sendRequest('repo.list').catch(() => null))?.ok
if (!hasAnyBaseRefSource) { /* expect possible throw from baseRefDefault */ }

Try / catch

let baseRef: string | null
try {
  baseRef = await resolveMobileBranchCompareBaseRef(client, worktreeId)
} catch (err) {
  // degrade gracefully — disable compare/rebase rather than crashing the screen
  baseRef = null
  reportNonFatal(err)
}
if (!baseRef) { setBranchCompareState({ kind: 'idle' }) }

Prevention

When it happens

Trigger: 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`).

Common situations: 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.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/80d66cc8ecc5f506. Report an issue: GitHub.