Repository navigation
fix(mocactl): sbx names the unreachable URL and keeps a failed login's URL - #858
Conversation
…s URL - An sbx call that cannot reach the control plane now names the URL it tried and suggests `mocactl sbx doctor` (as does a refresh that could not be asked). - `sbx login --control-plane-url URL` saves URL to config.json even when the login then fails (not enrolled, unreachable, abandoned), so `sbx doctor` and `sbx up` look at the control plane the user named. A URL that answers it is not a sandbox service is still not kept. - Changing the saved URL says so: "mocactl's sandbox control plane URL is changing from OLD to NEW" (nothing when there was none before). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Ed Snible <[email protected]>
Review on rossoctl#858: whether `sbx login` announces a URL change now uses sameControlPlane, as loadAuth does, rather than a trailing-slash-only comparison; and the comments say the URL is kept when discovery fails for any reason, not only when it is unreachable. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Ed Snible <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Review at 5f26327
fail/failRefresh now name the control plane they tried (through displayUrl + sanitizeRemote, so no userinfo or query reaches the screen) and point to mocactl sbx doctor. connection_dropped keeps its "closed the connection" wording instead of "cannot reach". sbx login --control-plane-url saves the URL once discovery says it is a sandbox or combined service, or when discovery or the login fails, but not when discovery answers that it is a non-sandbox service. It prints a change notice, using sameControlPlane to decide whether the URL really changed. I checked every caller of fail/failRefresh (only the sbx ones; workloads.ts has its own local fail). rememberOnce stops a double save between the try and catch paths. The tests cover each of the branches described.
Areas reviewed: TypeScript (mocactl sbx), tests
Agent/IDE config (.claude/.vscode): none
Commits: 2, all signed off
CI status: 13 passed, 4 pending at draft time (check, deploy-scripts, deploy-scripts-bash32, k8s-kind-e2e).
Base: 5 commits behind main, mergeable_state unknown
Suggestion (cli.ts:465-471, outside the diff)
openSbx's bound-sandbox warning (cli.ts:465-471) says that is not the control plane you logged in to (${remembered.sbxControlPlaneUrl}). After this PR, config.sbxControlPlaneUrl can be a URL whose login failed or never ran: unreachable, a typo, or not enrolled. So the warning can call a control plane "the one you logged in to" when the user never logged in there, and that line exists to tell a user which control plane to trust with their files. Consider wording it as "the control plane mocactl is configured for", or comparing against the URL in sbx-auth.json (storedLoginUrl), which is the real login. While you're there, that line uses sanitizeRemote without displayUrl, so it can still show a user:pass@ URL.
Drafted by an AI reviewer and approved by a human before posting.
| /** | ||
| * `sbx login --control-plane-url URL`'s URL, saved to config.json for the commands after it, and, | ||
| * when it replaces another, the change said out loud. Saved even when discovery fails for any | ||
| * reason, or the login after it fails (not enrolled, abandoned): the user named this control plane, so `sbx doctor` and the |
There was a problem hiding this comment.
nit: This JSDoc line is 124 chars, over the 100-col printWidth. Prettier doesn't rewrap comments, so please rewrap it by hand.
Summary
sbx: cannot reach the sandbox control plane: cannot reach the control plane: fetch failed (UND_ERR_CONNECT_TIMEOUT). It now printssbx: cannot reach the sandbox control plane at <url>: fetch failed (UND_ERR_CONNECT_TIMEOUT); runmocactl sbx doctorto diagnose. A login refresh that could not be asked also names the URL and suggests the doctor.sbx login --control-plane-url URLstill saves the URL. Before, the URL was saved only after a successful login, so after a "not enrolled" refusal,sbx doctorandsbx upkept using the old control plane. Now the URL is saved once discovery says it is a sandbox (or combined) service, or when discovery fails for any reason (unreachable, a 5xx, a page that is not JSON). The old login insbx-auth.jsondoes not match the new URL, so later commands ask for a login there rather than using it. A URL that answers that it is not a sandbox service is still not saved.sbx: mocactl's sandbox control plane URL is changing from OLD to NEW. Nothing is printed when there was no URL before, or when the new URL names the same control plane as the old one. That check usessameControlPlane, asloadAuthdoes, so differences in case, default port, or a trailing slash don't count as a change.Test plan
tsc --noEmitpasses, and Prettier passestest/sbx-cli.test.ts: the exact unreachable message; URL saved and the notice shown on a not-enrolled login, and later commands use the new URL; URL saved on an unreachable login; old URL kept for a non-sandbox control plane; no notice on a first login, or for the same control plane spelled differently (trailing slash; upper-case host with:443)--testTimeout=60000the affected files pass 383/383Assisted-By: Claude Code