Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 221504a The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
| const sshResponse = await promiseSpinner(mint(), { | ||
| message: "Authenticating", | ||
| }); |
There was a problem hiding this comment.
When stdin is a terminal but stdout is redirected, promiseSpinner() takes its noninteractive branch and writes Authenticating to stdout before the remote command output. This makes a command such as wrangler containers ssh <id> -- cat file >file produce a corrupted local file. Skip the spinner unless stdout is a terminal.
| const sshResponse = await promiseSpinner(mint(), { | |
| message: "Authenticating", | |
| }); | |
| const sshResponse = | |
| process.stdout.isTTY === true | |
| ? await promiseSpinner(mint(), { message: "Authenticating" }) | |
| : await mint(); |
|
I'm Bonk, and I've done a quick review of your PR. Adds keyless container shell sessions with TTY handling and legacy OpenSSH fallback.
|
There was a problem hiding this comment.
Superseded by the review of
221504a1.
This review, of 9707da80
💬 Approved with comments — One WARNING: ProxyCommand setups that pass a command after -- (for example -- %p) no longer get the SSH stdio proxy unless --legacy-openssh is added, and the changeset calls the auto-detection unchanged.
Findings: 1 warning (1 is an inline comment on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
🔧 Fix with your agent
Paste the following into your coding agent to investigate and fix these issues.
Fix the following code review issues found in pull request #17304.
Before making changes, review each issue and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g., the fix would require disproportionate changes
for minimal ROI, or the finding is factually incorrect), explain why
- If you need to clarify something before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order
## WARNING (1)
### [Code Quality] ProxyCommand auto-detection no longer applies when a command follows `--` (for example `-- %p`) unless `--legacy-openssh` is set, which breaks existing setups. The changeset calls the auto-detection unchanged.
- **File:** packages/containers-shared/src/ssh.ts:467
📋 Code Quality: ⚠️ 1 warning
ProxyCommand auto-detection now depends on whether a command is given, which breaks existing -- <port> setups.
Recommendation: 📝 Minor Comments
- [WARNING] ProxyCommand auto-detection no longer applies when a command follows
--(for example-- %p) unless--legacy-opensshis set, which breaks existing setups. The changeset calls the auto-detection unchanged. (packages/containers-shared/src/ssh.ts:467)
View full review
ProxyCommand auto-detection changes when a command follows -- (packages/containers-shared/src/ssh.ts:456-470)
On the base branch, shouldUseStdio returned true whenever stdin and stdout were both redirected and --tty was not set. Any trailing command was ignored. Now the redirected-stream case also needs legacyOpenssh === true || !command?.length. So an invocation like ProxyCommand wrangler containers ssh %h -- %p takes the new shell path and tries to run the port number as a command in the container, instead of proxying SSH traffic. The existing wrangler test that used containers ssh <id> -- 22 had to gain --legacy-openssh in this pull request to keep passing, which shows the old form used to work. .changeset/containers-keyless-ssh.md says "--stdio and the ProxyCommand auto-detection are unchanged". That holds only when no command is given.
Two ways to fix this: keep the old detection for redirected streams when no --tty/--no-tty is given, or state the break explicitly in the changeset (setups that use -- <port> must add --stdio or --legacy-openssh). Either way, a test without --legacy-openssh should pin down the intended behaviour.
✅ All other checks passed
🔒 Security: ✅ LGTM
The bearer token goes only to the URL the API returns, and the command is sent in the first WebSocket frame rather than in the URL. Malformed ACK and EXIT frames are handled safely, and the terminal is restored on every exit path. The OpenSSH code path now runs only behind --legacy-openssh.
📖 AGENTS.md: ✅ LGTM
No issues found.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The changeset statement that ProxyCommand auto-detection is unchanged is covered by the code quality finding on packages/containers-shared/src/ssh.ts:467.
Reviewed commit: 9707da80
| // An explicit --tty requests a terminal session, so it must not be | ||
| // mistaken for ProxyCommand usage when both streams are redirected. | ||
| (sshArgs.tty !== true && | ||
| (sshArgs.legacyOpenssh === true || !sshArgs.command?.length) && |
There was a problem hiding this comment.
ProxyCommand auto-detection no longer applies when a command follows -- (for example -- %p) unless --legacy-openssh is set, which breaks existing setups. The changeset calls the auto-detection unchanged.
On the base branch, redirected stdin and stdout always selected the stdio proxy, and a trailing command was ignored. With this condition, ProxyCommand wrangler containers ssh %h -- %p takes the new shell path and tries to run 22 in the container, so SSH stops connecting. The existing wrangler test for -- 22 had to add --legacy-openssh in this pull request to keep passing. Either keep the old detection when no --tty/--no-tty is given, or say in .changeset/containers-keyless-ssh.md that -- <port> ProxyCommand setups must now add --stdio or --legacy-openssh. The changeset currently calls the auto-detection "unchanged".
There was a problem hiding this comment.
This is on purpose. wrangler containers ssh <id> -- <cmd> should run <cmd> even when stdin and stdout are pipes, for example cat f | wrangler containers ssh <id> -- sh -c 'cat > /tmp/f'. Before, proxy mode ignored everything after --, so -- %p never did anything, and the docs only show ProxyCommand="wrangler containers ssh %h". I updated the changeset to call out the change: a ProxyCommand that passes arguments after -- needs --stdio.
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/cli-shared-helpers
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/test-server
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
| userAgent: string | ||
| ): Promise<number> { | ||
| const { stdin, stdout, stderr } = process; | ||
| const command = sshArgs.command?.length ? sshArgs.command : undefined; |
There was a problem hiding this comment.
🔍 Quoted remote commands change meaning
With -- 'pwd; whoami', runShell sends one executable name. The OpenSSH path sends a command string for the remote shell to interpret.
Was this helpful? React with 👍 or 👎 to provide feedback.
| const ws = new WebSocket(url, ["cf-container-shell.v1"], { | ||
| headers: { | ||
| authorization: `Bearer ${mint.token}`, | ||
| "user-agent": userAgent, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
🔍 Deployed shell handshake remains unverified
The shell fixture checks the request against a local WebSocket server. It does not verify that a production token works at /shell with the new subprotocol.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
I tested this against production: shells, commands, exit codes, PTY, resize and Ctrl-C all work against the live /shell endpoint with cf-container-shell.v1.
wrangler containers ssh now uses the Containers shell WebSocket by default. It needs no authorized_keys and no local OpenSSH. It allocates a PTY when stdin and stdout are terminals. --tty and --no-tty override that. The shared spinner now shows the cursor again when it stops without a message. Before, the cursor stayed hidden for the whole shell session. Commands run directly, without a remote shell. Output stops when the local reader closes the pipe, with exit code 141 as with SIGPIPE. The "Authenticating" spinner only shows when stdout is a terminal, so it does not mix with redirected output. The hidden OpenSSH options select the OpenSSH connection, as --legacy-openssh does. `containers-shared/src/shell.ts` implements the interface expected by the Containers shell "protocol". We also add a `--legacy-openssh` flag which is marked deprecated to support the existing OpenSSH option so that users that currently rely on this can keep using it (for now this is the only way to use port forwarding). The `legacy` in the option name is intentional, it's meant to be a clear signal to users that this option shouldn't be used or depended on.
9707da8 to
221504a
Compare
There was a problem hiding this comment.
✅ Approved — The one earlier warning is resolved: the changeset now documents the change to ProxyCommand handling when a command follows --. No new issues were found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
- The bearer token goes only to the URL the API returns.
- The command is sent in the first WebSocket frame, not in the URL.
- Malformed ACK and EXIT frames are handled safely.
- The OpenSSH path is used only with
--legacy-opensshor one of the OpenSSH options.
📖 AGENTS.md: ✅ LGTM
No issues found.
📋 Code Quality: ✅ LGTM
The changeset now says that a command after -- runs in the Container even when both streams are redirected, and that ProxyCommand setups passing arguments after -- must add --stdio. This matches shouldUseStdio in packages/containers-shared/src/ssh.ts, and the tests cover it.
I found no new defects:
- Raw mode, the listeners, stdin and the cursor are restored in
finally. - EPIPE on stdout is handled.
- The spinner change is covered by a test.
⚡ Performance: ✅ LGTM
Stdin backpressure and per-frame buffering are bounded, and listeners are cleaned up.
📝 Documentation: ✅ LGTM
The changesets match the behaviour of the code.
Reviewed commit: 221504a1
|
|
||
| Pass `--legacy-openssh` to use the previous connection with OpenSSH and the Container's authorized keys. `--legacy-openssh` is deprecated and will be removed in a future release. The hidden OpenSSH options also select this connection. | ||
|
|
||
| OpenSSH `ProxyCommand` setups keep working for port forwarding, SFTP and IDE tools such as VS Code Remote-SSH. With `--stdio`, or when stdin and stdout are both redirected and no command is given, Wrangler proxies SSH traffic to the Container as before. A command after `--` now runs in the Container, even when both streams are redirected. A `ProxyCommand` that passes arguments after `--` must add `--stdio`. |
There was a problem hiding this comment.
🔍 Redirected command docs omit OpenSSH exception
With both streams redirected, shouldUseStdio still selects proxy mode for -i or --legacy-openssh unless --tty is set. The changeset says a command after -- runs in the Container even with both streams redirected.
Was this helpful? React with 👍 or 👎 to provide feedback.
| const run = sshCommand({ id: "instance", command: ["yes"] }, "test-cli"); | ||
| const { socket, output } = await connected; | ||
| const closed = once(socket, "close"); | ||
| output(1, "y\n"); | ||
| await expect(run).resolves.toBe(141); | ||
| await closed; |
There was a problem hiding this comment.
🔍 Broken pipe test omits remote exit
The test leaves exited pending until the write fails. In openShell, a remote exit can settle it before the pending write reports EPIPE.
Was this helpful? React with 👍 or 👎 to provide feedback.
wrangler containers ssh now uses the Containers shell WebSocket by default. It needs no authorized_keys and no local OpenSSH. It allocates a PTY when stdin and stdout are terminals. --tty and --no-tty override that.
The shared spinner now shows the cursor again when it stops without a message. Before, the cursor stayed hidden for the whole shell session.
Commands run directly, without a remote shell. Output stops when the local reader closes the pipe, with exit code 141 as with SIGPIPE. The "Authenticating" spinner only shows when stdout is a terminal, so it does not mix with redirected output. The hidden OpenSSH options select the OpenSSH connection, as --legacy-openssh does.
containers-shared/src/shell.tsimplements the interface expected by the Containers shell "protocol".We also add a
--legacy-opensshflag which is marked deprecated to support the existing OpenSSH option so that users that currently rely on this can keep using it (for now this is the only way to use port forwarding). Thelegacyin the option name is intentional, it's meant to be a clear signal to users that this option shouldn't be used or depended on.See CC-9581.