Skip to content

fix(link): detect Windows Childs whose cmd echoes a stray quote - #9015

Closed
orshih6 wants to merge 1 commit into
lidge-jun:devfrom
orshih6:contribot/issue-8972
Closed

orshih6 wants to merge 1 commit into
lidge-jun:devfrom
orshih6:contribot/issue-8972

Conversation

@orshih6

@orshih6 orshih6 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Platform discovery ran cmd /c echo %OS% and required the answer to be exactly Windows_NT. With Microsoft's OpenSSH server, the bare cmd form answers Windows_NT" (one extra quote). The check failed, the uname fallback got a localized cmd error, and requireRemotePlatform threw a plain Error. The catch-all in probe() only builds hints from SshRunnerError, so the user got 502 probe_failed with no hint.

Changes:

  • WINDOWS_OS_PROBE is now cmd.exe /c echo %OS%. This is the form the reporter confirmed works.
  • A new isWindowsOsAnswer() trims the answer and ignores one leading or trailing quote. All three Windows_NT comparisons in remote-platform.ts now use it. The uname fallback is unchanged.
  • Platform discovery now throws RemotePlatformError, a subclass of Error with the same messages. probe() uses its bounded message as the hint, so a detection failure no longer looks like an SSH outage.
  • Tests and structure/remote-link.md now use the new probe literal.

Tests:

  • New unit test for isWindowsOsAnswer. It accepts Windows_NT, Windows_NT\r\n and Windows_NT"\r\n, and rejects unrelated output.
  • New route test: /api/link/probe succeeds when cmd answers Windows_NT"\r\n. When platform detection fails (localized uname refusal), it returns 502 with the hint Remote platform could not be determined.
  • bun test on the link argv, explicit-route, confirm-pin, enrollment, enrollment-operation, management-routes, cleanup, child-ops and sync-fanout test files: 380 pass, 0 fail. bun x tsc --noEmit is clean. I did not run the full bun run test, because the machine is small.

Not changed:

  • The CLI still prints only Link management request failed (502). errorCodeBody already keeps code and hint on the error, but changing what the CLI prints is a separate decision.
  • The GUI string "macOS or Linux on both computers" is still there, because it is translated in every locale.

Fixes #8972


This change was prepared with an AI coding agent (Claude) and reviewed by me before submitting. I'm happy to make any changes you'd like.

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Windows detection when connecting to remote systems, including responses that contain an extra surrounding quote.
    • Windows platform checks now use a more reliable command, helping avoid detection failures during remote-link setup.
    • When remote platform detection fails during enrollment, the failure response now includes a helpful explanation.

Signed-off-by: Бат-Орших <34618353+orshih6@users.noreply.github.com>
@github-actions github-actions Bot added the bug Something isn't working label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ⬜ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This PR stays in draft until every box above is ticked.

Hygiene

✅ Deterministic PR hygiene checks passed.

@github-actions
github-actions Bot marked this pull request as draft November 20, 2026 19:55
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Windows platform discovery now runs cmd.exe /c echo %OS% and accepts a quoted Windows_NT response. Platform-detection failures use RemotePlatformError; enrollment responses include its bounded message as a hint. Tests and remote-link documentation reflect these changes.

Changes: Windows remote link enrollment

Layer / File(s) Summary
Windows probe command and detection
src/link/ssh-argv.ts, src/link/remote-platform.ts, tests/clients/*link*.test.ts, tests/cli/sync-command-fanout.test.ts, tests/server/link-confirm-pin.test.ts
The Windows probe changes to cmd.exe. Platform checks accept Windows_NT with one surrounding quote. Tests cover accepted and rejected answers, updated probe commands, and argv fixtures that include -F none.
Enrollment probe failure hints
src/server/management/link-enrollment.ts, tests/server/link-management-routes.test.ts, structure/remote-link.md
Enrollment probe failures use the SSH runner hint when available, or a bounded RemotePlatformError message. Other errors still return probe_failed without a hint. Tests cover quoted Windows detection and an unsuccessful probe with a platform-detection hint. The documentation describes these behaviors.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • lidge-jun/opencodex#7496: Adds Windows classification for Remote Link Children and changes the Windows OS probe that this PR updates.
Merge Risk: Minimal · up to 3d5ff

This change makes Windows host probing over SSH tolerate a stray quote in the OS answer and report a clear hint when platform detection fails. No concrete merge-blocking risk was found. The change is small, covered by targeted tests, and easy to revert.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Out of Scope Changes check Inconclusive The core changes map to #8972: the probe literal in src/link/ssh-argv.ts, isWindowsOsAnswer and RemotePlatformError in src/link/remote-platform.ts, the hint path in src/server/management/link-enrollme… Confirm whether the -F none fixture changes in tests/clients/link-explicit-route.test.ts are required to match the current argv builders. If they are required, state that in the PR description. If they are not required, remove them from t…
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(link): detect Windows Childs whose cmd echoes a stray quote" matches the main change. The PR changes Windows platform detection for Remote Link enrollment. It switches the probe from `c…
Linked Issues check Passed Only #8972 is directly linked and active. Its coding requirements are: (1) a Windows probe over working key-based SSH returns fingerprint and version; (2) probe failures carry a hint; (3) detection to…
Full details: Title check

Explanation

The title "fix(link): detect Windows Childs whose cmd echoes a stray quote" matches the main change. The PR changes Windows platform detection for Remote Link enrollment. It switches the probe from cmd to cmd.exe and accepts Windows_NT with one stray surrounding quote through isWindowsOsAnswer(). The title has a typo: "Childs" should be "Child's" or a different word, and it is unclear. The phrase "Windows Childs" does not match any term in the changeset. The reader can still infer the main change, so the check passes with a wording note.

Full details: Linked Issues check

Explanation

Only #8972 is directly linked and active. Its coding requirements are: (1) a Windows probe over working key-based SSH returns fingerprint and version; (2) probe failures carry a hint; (3) detection tolerates the stray quote from Windows OpenSSH.

(1) and (3) [#8972]: src/link/ssh-argv.ts changes WINDOWS_OS_PROBE to "cmd.exe /c echo %OS%", the form the issue reports as working. src/link/remote-platform.ts adds isWindowsOsAnswer(), which trims and removes one leading or trailing quote. All three Windows comparisons (confirmWindowsShell, requireRemotePlatform, requireRemotePlatformFramed) use it. The uname fallback is unchanged.

(2) [#8972]: RemotePlatformError is thrown for the detection failures named in the issue ("SSH platform discovery failed", "Remote platform could not be determined"). src/server/management/link-enrollment.ts probe() catch now uses boundHint(error.message) for RemotePlatformError when sshRunnerErrorHint returns undefined. The issue asked that a detection failure not look like an SSH outage, and this meets that.

Limits: probe() maps only RemotePlatformError. Other non-SshRunnerError throws still produce no hint. The issue's broader expected text ("any failure at least carries its hint") is only partly met. The issue's stated motivation is platform detection, so this is treated as met. The CLI still prints only the 502 status, and the GUI hint text is unchanged. The PR states both as deliberate deferrals. Test results are author-reported; I did not inspect the test files.

Full details: Out of Scope Changes check

Explanation

The core changes map to #8972: the probe literal in src/link/ssh-argv.ts, isWindowsOsAnswer and RemotePlatformError in src/link/remote-platform.ts, the hint path in src/server/management/link-enrollment.ts, the doc update in structure/remote-link.md, and the Windows-probe test fixtures.

One change lacks a stated link to the issue. tests/clients/link-explicit-route.test.ts adds -F none to every saved explicit-route argv fixture. The summary describes this as documenting argv "before identity-file support". The PR description does not mention it. It does not touch platform detection or probe hints. It may be needed to match current builder output, but I did not verify that in the builder source. I did not confirm it as unrelated.

Resolution

Confirm whether the -F none fixture changes in tests/clients/link-explicit-route.test.ts are required to match the current argv builders. If they are required, state that in the PR description. If they are not required, remove them from this PR or move them to a separate change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a52a483 and 3d5fff9.

Files selected for processing: 10

  • src/link/remote-platform.ts
  • src/link/ssh-argv.ts
  • src/server/management/link-enrollment.ts
  • structure/remote-link.md
  • tests/cli/sync-command-fanout.test.ts
  • tests/clients/link-explicit-route-paths.test.ts
  • tests/clients/link-explicit-route.test.ts
  • tests/clients/link-ssh-argv.test.ts
  • tests/server/link-confirm-pin.test.ts
  • tests/server/link-management-routes.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@orshih6 orshih6 closed this Nov 21, 2026
@orshih6

orshih6 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

This was already fixed on dev by #9018 (a8f689f), which switches the probe to cmd.exe /c echo %OS%, accepts the stray Windows_NT" quote and adds a reason to the platform-detection 502. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

1 participant