{"record":{"id":"26d8bae7e6363d7e","repo":"stablyai/orca","slug":"branch-status-unavailable","errorCode":null,"errorMessage":"Branch status unavailable","messagePattern":"Branch status unavailable","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"mobile/src/source-control/use-mobile-git-requests.ts","lineNumber":63,"sourceCode":"        throw new Error(result?.error || 'Commit failed')\n      }\n      return result\n    },\n    [sendGitRequest]\n  )\n\n  const readUpstreamStatusForSync = useCallback(async (): Promise<MobileGitUpstreamStatus> => {\n    try {\n      return await sendGitRequest<MobileGitUpstreamStatus>('git.upstreamStatus')\n    } catch (err) {\n      const code = err instanceof Error ? (err as GitRequestError).code : undefined\n      const message = err instanceof Error ? err.message : String(err)\n      if (!isMobileGitUnavailable(code, message)) {\n        throw err\n      }\n      const status = await sendGitRequest<MobileGitStatusResult>('git.status')\n      if (!status.upstreamStatus) {\n        throw new Error('Branch status unavailable')\n      }\n      return status.upstreamStatus\n    }\n  }, [sendGitRequest])\n\n  const runGitSyncSteps = useCallback(async () => {\n    await sendGitRequest<unknown>('git.fetch')\n    await sendGitRequest<unknown>('git.pull')\n    const nextUpstream = await readUpstreamStatusForSync()\n    if (nextUpstream.ahead > 0) {\n      await sendGitRequest<unknown>('git.push')\n    }\n  }, [readUpstreamStatusForSync, sendGitRequest])\n\n  return { sendGitRequest, sendCommitRequest, runGitSyncSteps }\n}\n","sourceCodeStart":45,"sourceCodeEnd":80,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/source-control/use-mobile-git-requests.ts#L45-L80","documentation":"Thrown in the fallback branch of `readUpstreamStatusForSync`. When `git.upstreamStatus` fails with a mobile-git-unavailable code, the code degrades to `git.status` and reads `status.upstreamStatus`. If that field is absent (the branch has no upstream tracking configured), the sync cannot compute ahead/behind and this error is thrown. Non-git-unavailable failures re-throw the original error instead.","triggerScenarios":"Running `runGitSyncSteps` where `git.upstreamStatus` is unavailable on the host AND the fallback `git.status` returns a result with `upstreamStatus` missing/null — i.e. the current branch has no upstream (local-only branch, never pushed with `-u`).","commonSituations":"User creates a local branch and tries to Sync before setting an upstream; the upstream remote was deleted; HEAD is detached; the host build is old (no `git.upstreamStatus`) and the branch is untracked.","solutions":["Push the branch with upstream tracking first (`git push -u origin <branch>`).","Update the desktop host so `git.upstreamStatus` is supported natively.","If the branch is intentionally local, skip sync until an upstream is configured."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Check upstream tracking before offering Sync.\nif (!status.branch?.upstream) {\n  setSyncUnavailable('Set an upstream branch before syncing.')\n}","typeGuard":null,"tryCatchPattern":"// readUpstreamStatusForSync already degrades git.upstreamStatus → git.status;\n// treat 'Branch status unavailable' as 'no upstream' and skip push.\ntry {\n  const upstream = await readUpstreamStatusForSync()\n} catch (err) {\n  if (err instanceof Error && err.message === 'Branch status unavailable') {\n    // skip push; the branch is local-only\n  } else throw err\n}","preventionTips":["Push new branches with `-u` so upstream tracking exists before Sync.","Update the host to support `git.upstreamStatus` natively to avoid the fallback path.","Hide Sync for branches with no upstream."],"tags":["source-control","git","upstream","fallback","sync"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}