Skip to content

fix: 🐛 sbx up uses logged-in control plane - #912

Merged
evaline-ju merged 2 commits into
rossoctl:mainfrom
evaline-ju:mocactl-login
Nov 19, 2026
Merged

evaline-ju merged 2 commits into
rossoctl:mainfrom
evaline-ju:mocactl-login

Conversation

@evaline-ju

Copy link
Copy Markdown
Contributor

Summary

After mocactl sbx login to a new control plane, mocactl sbx up in a repo bound to the old one now uses the control plane you logged in to and rebinds, instead of failing with exit 3.

Fixes #889

Testing

E2E against a real control plane, in a scratch repo bound to an old control plane this machine has no login for:

  • v0.10.0: mocactl sbx up exits 3 with "not logged in … (from .sbx/sandbox.json)".
  • This branch:
    • push still refuses, and now suggests mocactl sbx up.
    • up warns that it is moving from the old control plane to the logged-in one, then creates a sandbox there, pushes and rebinds.
    • A second push uses the new binding with no flag or MOCACTL_SBX_URL.
    • rm cleaned up the sandbox and the binding.

Assisted-By: Claude Code

Checklist

  • Commits are signed off (git commit -s).
  • make lint and the tests for the touched packages pass.
  • Docs: changed behavior, flags or environment variables are reflected in the relevant README or
    docs/ page, with the right maturity label (see docs/CONTRIBUTING-DOCS.md).
  • Docs: make check-links passes if any Markdown changed.
  • A new spec or ADR is registered in docs/specs/README.md or docs/adrs/README.md. - N/A

@evaline-ju
evaline-ju requested a review from pdettori as a code owner November 19, 2026 06:13
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Nov 19, 2026
@pdettori pdettori added this to the v0.11.0 milestone Nov 19, 2026

@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 — fix: sbx up uses the logged-in control plane

When a repository is bound to a control plane this machine has no login for, up now uses the control plane it is logged in to and rebinds, instead of failing; and it never asks a control plane for the bound sandbox id when the flag or MOCACTL_SBX_URL names a different one.

Verified

  • Scope: the whole block is inside if (command === 'up') (cli.ts:1210-1232), so run/push/pull/exec behaviour is unchanged. up is not in TAKES_SANDBOX_FLAG, so the later binding read at :1281 cannot undo the fallback by re-setting boundUrl.
  • The fallback's conditions are the right ones: no flag, no MOCACTL_SBX_URL, a bound URL, a cached login for the fallback URL and none for the bound one. loadAuth matches through sameControlPlane/canonicalControlPlaneUrl (config.ts:184-205), so a trailing-slash or spelling variant of the same endpoint still counts as logged in and does not trigger a rebind.
  • There is no other credential source: mocactl has no env/flag token, so "no loadAuth entry" really does mean "this machine cannot reach that control plane".
  • The second guard is a real fix: with --control-plane-url (or the env var) naming another control plane, upBound is cleared, so the bound id is never requested from a control plane that never issued it — the new test asserts no /v1/sandboxes/<id> call.
  • Tests cover the four paths (rebind + one create, keep the binding when the login is for it, flag case, no login for either with no sbx up hint) and the hint added in openSbx; CI is 18/18 green. The new docs paragraph and the embedded SBX_USAGE text in cli.ts say the same thing.

One suggestion inline (cli.ts:1224) about what the rebind warning tells the user.

Author: evaline-ju (MEMBER — maintainer). Agent/IDE config: none. Commits: 1, signed off.

Comment thread packages/mocactl/src/sbx/cli.ts Resolved
Signed-off-by: Evaline Ju <[email protected]>
@evaline-ju
evaline-ju merged commit ee17d0d into rossoctl:main Nov 19, 2026
18 checks passed
@evaline-ju
evaline-ju deleted the mocactl-login branch November 19, 2026 15:34
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.

mocactl sbx: a stale .sbx/sandbox.json control plane overrides the one just logged in to

3 participants