Skip to content

Stop reporting supported Linux hosts as an unsupported remote platform - #12209

Merged
nwparker merged 2 commits into
mainfrom
nwparker/bugbash-11104
Aug 3, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/bugbash-11104

Conversation

@nwparker

@nwparker nwparker commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Connecting to a perfectly supported Linux x86_64 host could fail with Unsupported remote platform. Orca relay supports: linux-x64, ..., and nothing in the logs said why.

detectRemoteHostPlatform collapsed four very different outcomes into a single null: src/main/ssh/ssh-remote-platform-detection.ts:36 swallowed every non-abort failure of the uname probe (a session channel refused past MaxSessions, the 30s exec timeout, a non-zero exit, a transport drop), :59 did the same for the PowerShell fall-back probe, and parseRemotePlatformOutput at :65 dropped the remote's raw stdout on the floor when no marker line was found (restricted shell / ForceCommand). src/main/ssh/ssh-relay-deploy.ts:363-366 (reached from the sole call site at :362) then turned every one of those nulls into the hardcoded "Unsupported remote platform" message. Those line numbers are on the base commit, c9a37f5.

The probe now classifies its outcome — detected / unsupported / unparsed / failed — and null is reserved for the one case the message is actually true for: a marker line that parsed but named a platform the relay does not ship (e.g. FreeBSD x86_64). Everything else throws:

  • a transport-shaped failure from either probe wins (Could not detect the remote platform: (SSH) Channel open failure: open failed), with the original error attached as cause. This is deliberate: on a Windows remote whose PowerShell probe is refused, the old ordering would have surfaced the uname probe's mundane non-zero exit instead — Command "printf '\n%s ' '__ORCA_REMOTE_PLATFORM__'; uname -sm" failed (exit 127): sh: not found — and told the user their Windows box is missing a shell;
  • otherwise the uname probe's error, then its unrecognized output, then the PowerShell probe's error;
  • unrecognized output is reported verbatim (whitespace-collapsed, last 200 chars, with a leading … when truncated) so ForceCommand/banner cases are actionable.

One console.warn on the failure path carries a longer (1000-char) tail of whatever the remote actually printed — the diagnostic that was missing when #8324 (same symptom, still open) was triaged.

The Windows fall-through is preserved for every ordinary uname failure, including a session-limit refusal: SshConnection.exec routes through openSessionChannelWithRetry on the ssh2 transport, so probe 2 gets its own retry-with-backoff budget after probe 1's channel slot is released. There is exactly one new case where the PowerShell probe is skipped: the uname probe rejected with an AbortError, or with an error whose channel close was never confirmed (sshChannelCloseConfirmed === false — the system-ssh timeout/abort/stream-error path). An ordinary non-zero exit never carries that flag, so a Windows remote answering sh: not found still falls through exactly as before. ssh-relay-deploy.ts is unchanged.

Closes #11104

ELI5

Orca asks your remote machine "what kind of computer are you?" before it installs its helper. If that question failed for any reason at all — the server was too busy to open another channel, the answer timed out, the login banner ate the reply — Orca shrugged and told you "your computer isn't supported", even when it was a completely ordinary Linux machine. That message was almost always a lie, and it hid the real problem.

Now Orca tells you what actually went wrong, and shows you what the remote machine really printed back. It only says "unsupported" when the machine genuinely answered with a platform Orca has no helper for.

Fix proof

Before — from a scratch repro file run against main (ssh-remote-platform-detection.bug-11104.test.ts; it is deliberately not part of this diff, both of its cases were folded into the real suite):

 FAIL  src/main/ssh/ssh-remote-platform-detection.bug-11104.test.ts > bug #11104: Linux x86_64 reported as an unsupported remote platform > does not misreport a refused exec channel as an unsupported platform
AssertionError: promise resolved "null" instead of rejecting

- Expected:
Error {
  "message": "rejected promise",
}

+ Received:
null

 ❯ src/main/ssh/ssh-remote-platform-detection.bug-11104.test.ts:25:49
     23|
     24|     // The host is linux-x64 and fully supported; the probe never ran.
     25|     await expect(detectRemoteHostPlatform(conn)).rejects.toThrow(/open…
       |                                                 ^
     26|   })
     27|

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯

 FAIL  src/main/ssh/ssh-remote-platform-detection.bug-11104.test.ts > bug #11104: Linux x86_64 reported as an unsupported remote platform > reports the raw probe output when a POSIX host yields no marker line
AssertionError: promise resolved "null" instead of rejecting

- Expected:
Error {
  "message": "rejected promise",
}

+ Received:
null

 ❯ src/main/ssh/ssh-remote-platform-detection.bug-11104.test.ts:35:49
     33|     // Correct behaviour surfaces what the remote actually printed so …
     34|     // can act; today every failure collapses into "Unsupported remote…
     35|     await expect(detectRemoteHostPlatform(conn)).rejects.toThrow(/pc-s…
       |                                                 ^
     36|   })
     37| })

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[2/2]⎯


 Test Files  1 failed (1)
      Tests  2 failed (2)
   Start at  21:59:26
   Duration  179ms (transform 74ms, setup 0ms, import 94ms, tests 4ms, environment 0ms)

After — both repro cases now live in src/main/ssh/ssh-remote-platform-detection.test.ts alongside 9 more classification cases (11 new its; the file goes from 6 to 17 tests):

 RUN  v4.1.5 /Users/nwparker/projects/orca/.claude/worktrees/wf_fc305741-745-1


 Test Files  1 passed (1)
      Tests  17 passed (17)
   Start at  02:07:12
   Duration  184ms (transform 72ms, setup 0ms, import 109ms, tests 7ms, environment 0ms)

No regressions

Every SSH suite plus the SSH IPC suite (src/main/ssh/, src/main/ipc/ssh.test.ts) — this covers ssh-relay-deploy, ssh-relay-native-deps-install, ssh-relay-sftp-namespace-install, ssh-relay-gc-retry, ssh-relay-cross-version-isolation, ssh-remote-platform, relay-protocol and the rest:

 RUN  v4.1.5 /Users/nwparker/projects/orca/.claude/worktrees/wf_fc305741-745-1

[ssh-relay] GC: lock at /home/u/.orca-remote/relay-0.1.0+aaa/.install-lock is stale; treating as recoverable
[ssh-relay] GC: lock at /home/u/.orca-remote/relay-0.1.0+aaa/.install-lock is stale; treating as recoverable

 Test Files  87 passed | 2 skipped (89)
      Tests  1302 passed | 13 skipped (1315)
   Start at  02:03:21
   Duration  16.28s (transform 27.14s, setup 0ms, import 51.39s, tests 28.27s, environment 5ms)

src/shared/process-output-field-scanner.test.ts (the parser this file consumes): Test Files 1 passed (1) / Tests 5 passed (5).

CI: currently green — no failing checks on head 7aad524. The first attempt of the PR Checks run had exactly one red check, shard tests node 26 15/16, failing src/renderer/src/components/activity/activity-portal-readiness-loop.react185.test.tsx > releases a latched readiness once the terminal attaches with expected 'unavailable' to be 'ready'. That is the repo-wide happy-dom MutationObserver flake (the test's own comments note that "under CI load MutationObserver may miss one replaceChildren"); it is a renderer test with no connection to this main-process SSH diff, and the identical failure hit unrelated branch #12212 the same day. The re-run passed with no code change.

Trade-offs

  • The error text is rawer. Where users used to get one tidy (wrong) sentence, they can now get up to 200 characters of their own host's banner or shell error, plus the probe command string in an exec-failure message — the same shape every other relay exec failure already surfaces. It is the user's own output, shown only to them, collapsed to a single line and length-capped.
  • Some connects that used to fail with a friendly-sounding message now fail with something the user has to act on (raise MaxSessions, fix ForceCommand, install /bin/sh). That is the point, but it is a change in tone.
  • Latency on the pathological path is unchanged (still up to two 30s probes). Short-circuiting the second probe on a session-limit refusal would have halved it, but that refusal is exactly the case where the second probe still has a real chance of succeeding, so the second attempt is kept.
  • Honest scope: this does not by itself prove the reporter's connect will now succeed — the remote-side trigger was never reproducible from field data, because the code logged nothing about the probe. It removes the misdiagnosis and makes the true cause visible. [Bug]: SSH remote connection to Linux (x86_64) prompts an unsupported error. #11104 asks that a supported Linux x86_64 host stop being reported as unsupported; that is what this closes — the message is now unreachable unless the remote genuinely named a platform the relay does not ship. [Bug]: Error: Unsupported remote platform on Linux x86_64 (Ubuntu 20.04) #8324 is the same symptom and is intentionally left open until a field report confirms the new diagnostics.
  • Verification scope: unit tests only, with execCommand mocked throughout — run locally on macOS and on Linux (ubuntu-latest) in CI. No live SSH connection, no real Windows or Cygwin remote, and no MaxSessions-saturated sshd was exercised end to end; the session-limit, timeout and unconfirmed-close shapes are reproduced from the error objects those code paths construct, not from a real server.

Cross-platform

Main-process Node only. No keyboard handling, no metaKey, no Electron accelerators, no shortcut labels, no path construction (joinRemotePath and getRemoteHostPlatform are untouched), no UI code. Identical behavior on macOS, Linux and Windows clients.

Remote-side platform handling is the subject of the change and is preserved for all six relay targets: POSIX remotes via the unchanged uname -sm probe (same command string, still asserted by the existing test), Windows remotes via the unchanged PowerShell fall-back (still reached whenever the uname probe fails to detect, including its /bin/sh non-zero exit; still wrapCommand: false, same -EncodedCommand payload). The one new gate on that fall-back is the abort / unconfirmed-close short-circuit described in the summary. The new unsupported classification deliberately runs after detected on both probes, so a Cygwin remote whose uname -s reports CYGWIN_NT-10.0 still falls through to PowerShell and is detected as win32 — covered by a new test. CRLF is handled by iterateProcessOutputLines, and the summarizer collapses both CR and LF so a Windows banner cannot produce a multi-line message.

SSH-remote: this is entirely the SSH path; nothing here assumes local execution. Both transports are covered because the change sits downstream of execCommand and only reclassifies its rejections — ssh2 (conn.exec → openSessionChannelWithRetry) and system-ssh (conn.exec → spawnTrackedSystemSshCommand, which has no session-channel retry of its own). The "unconfirmed channel close" short-circuit is transport-aware by construction: execCommand deliberately leaves sshChannelCloseConfirmed false for system-ssh channels because a local OpenSSH child exit does not prove the remote command stopped, so on system-ssh we skip a probe that would race a still-held ControlMaster slot.

Folder workspaces (non-git): platform detection runs before any workspace exists. No git command is added, changed or version-gated; no GitCapabilityCache interaction, no git-provider surface, no -c-leading git command affected.

Performance

No new remote round trips. The happy path is byte-for-byte unchanged: a detected uname probe returns after exactly one exec, as before. One 30s exec is saved only where the first probe is abandoned: the unconfirmed-termination case (where the second probe was near-certain to be refused anyway) and an AbortError that the caller's own signal does not already re-throw. No round-trip saving on session-limit — that "saving" would have been a lost retry, and is given back deliberately.

summarizeProbeOutput runs at most twice per failed connect, on a string already bounded to 1 MiB by appendExecOutputTail; a single bounded pass on an error path only. No polling, no timers, no new spawns, no extra IPC (the error travels on the existing ssh:connect reply — ssh-relay-deploy.ts:362 is the only call site), no renderer re-renders.

Security

No change to IPC surface, auth, or path handling. Command execution is unchanged — same two probe command strings, same wrapping flags. The one new exposure is diagnostic: up to 200 chars of the remote's own probe output in the thrown message and 1000 chars in the local log. It is the connecting user's own host output, shown only to that user; install-marker redaction is not needed because detection runs before any install marker exists, and execCommand already redacts marker tokens in its own non-zero-exit and timeout messages.

AI Review Report

Reviewed by independent subagents in a loop until clean, across two hostile lenses — correctness/regressions and cross-platform + remote + performance.

  • Review loop count: 2 round(s)
  • Final verdict: CLEAN
  • Outstanding findings: none — the final round returned zero blocker/major findings from both lenses.

Remediation applied between rounds: 1 pass(es) — it produced the second commit, which lets a refused PowerShell probe outrank an unmappable uname, plus its test. Findings judged false-positive were rejected with evidence rather than coded around.

Made with Orca 🐋

detectRemoteHostPlatform collapsed a refused session channel, an exec
timeout, a non-zero exit and marker-less banner output into the same
`null`, which ssh-relay-deploy.ts:362 rendered as "Unsupported remote
platform" — so a fully supported linux-x64 host was blamed for being
unsupported and nothing about the real cause was logged.

The probe now classifies its outcome (detected / unsupported / unparsed /
failed) and reserves `null` for a uname that genuinely parsed to an
unsupported platform. Everything else throws with the underlying cause or
the raw probe output, and logs a longer whitespace-collapsed tail.

The Windows fall-through is unchanged, including the second attempt after
a session-limit refusal, which gets its own session-channel retry budget.

Closes #11104
@coderabbitai

coderabbitai Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Remote platform detection now uses structured outcomes for detected, unsupported, unparsed, and failed probes. It preserves transport errors, handles cancellation and unconfirmed SSH termination, truncates diagnostic output, and applies prioritized error reporting. Uname and PowerShell probes return structured failures. Tests now cover retries, channel refusals, cancellation, malformed output, error precedence, unsupported platforms, output truncation, and Cygwin fallback to PowerShell.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #11104 by distinguishing probe failures from unsupported platforms and exposing the underlying detection failure.
Out of Scope Changes check ✅ Passed The implementation and tests remain focused on SSH remote platform detection and the linked issue objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes the main change: preventing supported Linux hosts from being reported as unsupported.
Description check ✅ Passed The description explains the change, testing, cross-platform impact, security considerations, risks, and review results, with only minor template sections omitted.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/ssh/ssh-remote-platform-detection.ts (1)

17-17: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Make the timeout matcher tolerate fractional seconds.

execCommand formats the timeout message with ${timeoutMs / 1000}s. A non-multiple of 1000 produces 1.5s, which /timed out after \d+s$/u does not match. The timeout then loses transport precedence in undetectedPlatformError.

♻️ Proposed regex change
-const EXEC_TIMEOUT_MESSAGE = /timed out after \d+s$/u
+const EXEC_TIMEOUT_MESSAGE = /timed out after \d+(?:\.\d+)?s$/u

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e60ede67-71ca-4bdb-9e4b-26827d6689fe

📥 Commits

Reviewing files that changed from the base of the PR and between c9a37f5 and 9befca5.

📒 Files selected for processing (2)
  • src/main/ssh/ssh-remote-platform-detection.test.ts
  • src/main/ssh/ssh-remote-platform-detection.ts

An unmappable uname (Cygwin on a Windows OpenSSH host) is only settled by
the PowerShell probe, but the unsupported short-circuit ran before that
probe outcome was inspected — so a MaxSessions refusal was discarded and a
win32-x64 host was reported as an unsupported platform.

Co-authored-by: Orca <[email protected]>
@nwparker
nwparker merged commit 1dbf55e into main Aug 3, 2026
82 of 84 checks passed
@nwparker
nwparker deleted the nwparker/bugbash-11104 branch August 3, 2026 07:50
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SSH remote connection to Linux (x86_64) prompts an unsupported error.

1 participant