{"record":{"id":"0cc9288784c4a4a4","repo":"stablyai/orca","slug":"response-error-code-response-error-message-0cc928","errorCode":null,"errorMessage":"${response.error.code}: ${response.error.message}","messagePattern":"\\$\\{response\\.error\\.code\\}: \\$\\{response\\.error\\.message\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mobile/src/transport/pre-profile-pairing-coordinator.ts","lineNumber":287,"sourceCode":"    endpoints: [\n      { id: 'direct-primary', kind: 'lan', url: host.endpoint },\n      { id: 'relay-primary', kind: 'relay', url: relayWebSocketUrl(relay) }\n    ],\n    relayHostId: relay.relayHostId,\n    relay\n  }\n}\n\nfunction relayWebSocketUrl(relay: MobileRelayEndpoint): string {\n  const url = new URL(relay.cellUrl)\n  url.protocol = 'wss:'\n  url.pathname = `/v1/connect/${encodeURIComponent(relay.relayHostId)}`\n  return url.toString()\n}\n\nfunction requireSuccess(response: RpcResponse): unknown {\n  if (!response.ok) {\n    throw new Error(`${response.error.code}: ${response.error.message}`)\n  }\n  return response.result\n}\n\nfunction isMethodNotFound(response: RpcResponse): boolean {\n  return !response.ok && response.error.code === 'method_not_found'\n}\n\nfunction assertCommittedInstall(\n  status:\n    | { state: 'not-found' }\n    | { state: 'committed'; result: DeviceCredentialInstalled }\n    | undefined,\n  installed: DeviceCredentialInstalled\n): void {\n  if (\n    !status ||\n    status.state !== 'committed' ||","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/mobile/src/transport/pre-profile-pairing-coordinator.ts#L269-L305","documentation":"The generic RPC-failure throw in requireSuccess (line 285-290). Called for provisionRelay and pairing.getEndpoints results in runPairing: if response.ok is false and the error is not method_not_found (handled separately by isMethodNotFound), the raw JSON-RPC error code and message are concatenated and rethrown. This is the catch-all that surfaces any server-returned RPC failure — auth errors, invalid params, internal errors — preserving the desktop's own error vocabulary.","triggerScenarios":"winner.client.sendRequest returned an RpcFailure (ok:false) with any error.code other than 'method_not_found'. Common codes: 'invalid_params' (wrong installReqId, mismatched newResumeTokenHash), 'internal_error' (desktop crashed during install), 'auth_error' (deviceToken rejected), or relay-propagated errors. The message format is '<code>: <message>'.","commonSituations":"Pairing against a desktop whose install state is inconsistent (installReqId unknown → invalid_params), a desktop that lost its credential store between provisionRelay and getEndpoints, or a relay that forwarded a 5xx-derived RPC error. Also surfaces when the resume token hash in the journal doesn't match what the desktop expects.","solutions":["Parse the '<code>: <message>' string: the code determines the fix — 'invalid_params' means check installReqId/newResumeTokenHash in the journal; 'auth_error' means re-pair; 'internal_error' means inspect desktop logs.","Clear the mobile relay pairing journal (clearMobileRelayPairingJournal) and re-initiate pairing to get a fresh installReqId.","On the desktop, check logs for the matching reqId to see why the RPC rejected.","If the code is relay-specific, retry over the direct path by ensuring the direct candidate wins the race."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"interface RpcFailureLike { code: string; message: string }\nfunction parseRpcFailureMessage(error: unknown): RpcFailureLike | null {\n  if (!(error instanceof Error)) return null\n  const match = /^(\\w+): (.+)$/.exec(error.message)\n  return match ? { code: match[1], message: match[2] } : null\n}","tryCatchPattern":"try {\n  await winner.client.sendRequest('pairing.provisionRelay', params)\n} catch (error) {\n  const failure = parseRpcFailureMessage(error)\n  if (failure) {\n    switch (failure.code) {\n      case 'invalid_params': /* check installReqId/resumeTokenHash */ break\n      case 'auth_error': /* re-pair */ break\n      case 'internal_error': /* inspect desktop logs */ break\n    }\n  }\n  throw error\n}","preventionTips":["Inspect the '<code>: <message>' format to route recovery by error code.","Clear the mobile relay pairing journal and re-pair to get a fresh installReqId when codes suggest state corruption.","Correlate the reqId in desktop logs when this surfaces in production."],"tags":["rpc","pairing","json-rpc","error-propagation"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}