Skip to content

fix(mocactl): sbx names the unreachable URL and keeps a failed login's URL - #858

Merged
esnible merged 2 commits into
rossoctl:mainfrom
esnible:fix/sbx-login-remembers-url
Nov 17, 2026
Merged

esnible merged 2 commits into
rossoctl:mainfrom
esnible:fix/sbx-login-remembers-url

Conversation

@esnible

@esnible esnible commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Unreachable message names the URL and the next step. An sbx call that times out used to print sbx: cannot reach the sandbox control plane: cannot reach the control plane: fetch failed (UND_ERR_CONNECT_TIMEOUT). It now prints sbx: cannot reach the sandbox control plane at <url>: fetch failed (UND_ERR_CONNECT_TIMEOUT); run mocactl sbx doctor to diagnose. A login refresh that could not be asked also names the URL and suggests the doctor.
  • A failed sbx login --control-plane-url URL still saves the URL. Before, the URL was saved only after a successful login, so after a "not enrolled" refusal, sbx doctor and sbx up kept 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 in sbx-auth.json does 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.
  • Change notice. When the saved URL changes, login prints 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 uses sameControlPlane, as loadAuth does, so differences in case, default port, or a trailing slash don't count as a change.

Test plan

  • tsc --noEmit passes, and Prettier passes
  • New tests in test/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)
  • All sbx/TUI test files pass. On a loaded machine some tests hit the 5s default timeout; with --testTimeout=60000 the affected files pass 383/383

Assisted-By: Claude Code

…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]>
@esnible
esnible requested a review from pdettori as a code owner November 17, 2026 16:53
@pdettori pdettori added this to the v0.11.0 milestone Nov 17, 2026
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 17, 2026
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 ingpaolodettori-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: This JSDoc line is 124 chars, over the 100-col printWidth. Prettier doesn't rewrap comments, so please rewrap it by hand.

@esnible
esnible merged commit f5aefec into rossoctl:main Nov 17, 2026
18 checks passed
@esnible
esnible deleted the fix/sbx-login-remembers-url branch November 17, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants