{"record":{"id":"04fda0e578bc8fe3","repo":"stablyai/orca","slug":"rpc-error-message-04fda0","errorCode":null,"errorMessage":"${RPC error message}","messagePattern":"\\$\\{RPC error message\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mobile/src/files/mobile-file-tab-doc.ts","lineNumber":39,"sourceCode":"  diffSource?: 'staged' | 'unstaged' | 'branch' | 'commit'\n}\n\n// Throws 'binary_file'/'file_too_large'/the RPC error message; callers map those\n// to error docs.\nexport async function resolveMobileFileTabDoc(\n  client: FileTabDocClient,\n  request: MobileFileTabDocRequest\n): Promise<MobileFileTabDoc> {\n  const worktree = `id:${request.worktreeId}`\n  const { relativePath } = request\n  if (request.diffSource === 'staged' || request.diffSource === 'unstaged') {\n    const response = await client.sendRequest('git.diff', {\n      worktree,\n      filePath: relativePath,\n      staged: request.diffSource === 'staged'\n    })\n    if (!response.ok) {\n      throw new Error((response as RpcFailure).error.message)\n    }\n    const result = (response as RpcSuccess).result as\n      | { kind: 'text'; originalContent: string; modifiedContent: string }\n      | MobileBinaryDiffResult\n    if (result.kind !== 'text') {\n      // Render image diffs (add/modify/delete) from the base64 the host already\n      // sends; only non-previewable binaries stay unavailable.\n      const dataUri = mobileDiffImageDataUri(result)\n      if (!dataUri) {\n        throw new Error('binary_file')\n      }\n      return { status: 'ready', kind: 'image', dataUri }\n    }\n    const diff = buildMobileDiffLines(result.originalContent, result.modifiedContent)\n    return { status: 'ready', kind: 'diff', lines: diff.lines, truncated: diff.truncated }\n  }\n\n  const artifactKind = classifyMobileArtifact(relativePath)","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/files/mobile-file-tab-doc.ts#L21-L57","documentation":"Thrown by resolveMobileFileTabDoc when the staged/unstaged diff path fails. For diffSource 'staged' or 'unstaged', it calls git.diff with the worktree, filePath, and staged flag; if the host returns {ok:false} the error message is re-thrown. This typically surfaces 'file_too_large', path-not-found, or git errors from the host.","triggerScenarios":"client.sendRequest('git.diff', {worktree: `id:${worktreeId}`, filePath: relativePath, staged: boolean}) returns {ok:false}. Causes: file does not exist at that revision, file is binary-only with no text diff (host may emit a specific code), git binary on host errored, worktree missing, path is a directory.","commonSituations":"User opens a diff tab for a file deleted in the working tree; the host's git binary failed on a corrupt index; very large files where the host caps diff size; race where the file was renamed between snapshot and diff request.","solutions":["Map known codes: 'file_too_large' and 'binary_file' are produced elsewhere in this file — handle them in the caller as distinct doc states rather than generic errors.","Verify relativePath still exists at the requested diffSource via the file tree before re-opening the tab.","If the worktree was rotated, navigate back to the worktree list and re-open the file.","For host git errors, check the desktop's git capability cache and logs."],"exampleFix":"// before\nif (!response.ok) {\n  throw new Error((response as RpcFailure).error.message)\n}\n\n// after — normalize known codes the caller already maps\nif (!response.ok) {\n  const code = (response as RpcFailure).error?.code\n  if (code === 'file_too_large') throw new Error('file_too_large')\n  if (code === 'binary') throw new Error('binary_file')\n  throw new Error((response as RpcFailure).error.message)\n}","handlingStrategy":"try-catch","validationCode":"// Confirm the file path exists at the requested diffSource before opening\nconst entries = await client.sendRequest('files.readDir', { worktree, relativePath: dirname(relativePath) })\nif (!entries.ok) return","typeGuard":"function isBinaryFileError(err: unknown): boolean {\n  return err instanceof Error && err.message === 'binary_file'\n}\nfunction isFileTooLargeError(err: unknown): boolean {\n  return err instanceof Error && err.message === 'file_too_large'\n}","tryCatchPattern":"try {\n  return await resolveMobileFileTabDoc(client, request)\n} catch (err) {\n  if (isBinaryFileError(err)) return { status: 'ready', kind: 'binary' } as any\n  if (isFileTooLargeError(err)) return { status: 'ready', kind: 'too_large' } as any\n  setErrorDoc(err.message)\n}","preventionTips":["Map known host codes ('file_too_large', 'binary') to dedicated doc states instead of generic errors.","Refresh the file tree before re-opening a diff tab to catch deleted/renamed files.","Avoid opening diffs for paths the host flagged binary in the snapshot."],"tags":["rpc","git","diff","files","typescript"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}