{"record":{"id":"52c2584142da4782","repo":"stablyai/orca","slug":"ssh-connection-args-targetid-not-found","errorCode":null,"errorMessage":"SSH connection \"${args.targetId}\" not found","messagePattern":"SSH connection \"(.+?)\" not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/ipc/ssh.ts","lineNumber":1526,"sourceCode":"  })\n\n  // ── Port forwarding ─────────────────────────────────────────────────\n\n  ipcMain.handle(\n    'ssh:addPortForward',\n    async (\n      _event,\n      args: {\n        targetId: string\n        localPort: number\n        remoteHost: string\n        remotePort: number\n        label?: string\n      }\n    ) => {\n      const conn = connectionManager!.getConnection(args.targetId)\n      if (!conn) {\n        throw new Error(`SSH connection \"${args.targetId}\" not found`)\n      }\n      const entry = await portForwardManager!.addForward(\n        args.targetId,\n        conn,\n        args.localPort,\n        args.remoteHost,\n        args.remotePort,\n        args.label\n      )\n      persistPortForwards(args.targetId)\n      broadcastPortForwards(getCurrentMainWindow, args.targetId)\n      return entry\n    }\n  )\n\n  ipcMain.handle(\n    'ssh:updatePortForward',\n    async (","sourceCodeStart":1508,"sourceCodeEnd":1544,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/ssh.ts#L1508-L1544","documentation":"Thrown by the 'ssh:addPortForward' IPC handler when connectionManager.getConnection(args.targetId) returns falsy. Port forwarding requires a live underlying SSH connection (the node-ssh/transport channel) to open the tunnel; without it, portForwardManager.addForward has nothing to bind to. The guard fails fast rather than letting addForward throw a less clear internal error.","triggerScenarios":"Renderer invokes addPortForward for a targetId that is not currently connected — either never connected, disconnected, or mid-reconnect. The connectionManager has no Connection object keyed by that targetId at the moment of the call.","commonSituations":"User tries to add a forward before the SSH session finishes connecting. The connection dropped and the renderer did not yet reflect the disconnected state. A saved-forward auto-restore fires on startup before the session is live.","solutions":["Ensure the SSH target is fully connected (await connect) before adding a port forward.","If auto-restoring saved forwards, queue them until the connection-ready event fires.","Surface the disconnected state in the UI so the user connects first."],"exampleFix":"// before\nipcRenderer.invoke('ssh:addPortForward', { targetId, localPort, remoteHost, remotePort })\n// after\nawait ipcRenderer.invoke('ssh:connect', { targetId })\nipcRenderer.invoke('ssh:addPortForward', { targetId, localPort, remoteHost, remotePort })","handlingStrategy":"validation","validationCode":"const state = await ipcRenderer.invoke('ssh:getState', { targetId })\nif (state.status !== 'connected') {\n  await ipcRenderer.invoke('ssh:connect', { targetId })\n}\nawait ipcRenderer.invoke('ssh:addPortForward', { targetId, localPort, remoteHost, remotePort })","typeGuard":null,"tryCatchPattern":"try {\n  await ipcRenderer.invoke('ssh:addPortForward', { targetId, localPort, remoteHost, remotePort })\n} catch (e) {\n  if (/SSH connection .* not found/.test((e as Error).message)) {\n    await ipcRenderer.invoke('ssh:connect', { targetId })\n    await ipcRenderer.invoke('ssh:addPortForward', { targetId, localPort, remoteHost, remotePort })\n  } else throw e\n}","preventionTips":["Connect the target fully before adding forwards.","Queue auto-restored forwards until connection-ready fires.","Reflect connection status in the UI to gate the add-forward action."],"tags":["ssh","port-forwarding","connection","not-found","ipc"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}