Repository navigation
Description
Summary
On a machine whose bb server was moved to bb Connect, every agent thread on that machine gets HTTP 401: Unauthorized from the bb CLI, for example from bb thread show, bb project list, and bb machine list. The host daemon gives each thread an authenticated loopback proxy in BB_SERVER_URL. The bb-app launcher replaces it with serverUrl from the machine's config.json (the public https://<handle>.getbb.app URL), and the CLI calls that URL without the machine credential. Restarting doesn't help, because the config file is unchanged.
Versions and environment
- Affected machine: bb
0.43.4-nightly.35739502552.1, installed through the desktop app and npm into~/.bb, macOS on Apple silicon. It was originally the desktop-hosted server and is now a remote host of a bb Connect server (https://<handle>.getbb.app). - Minimal repro below: bb
0.43.5-nightly.35773768107.1, macOS 15.2 (Intel), Node 24.18.1. - Code cited at
maindea024ee6cdc8d482ca13713684e8495a112e142.
Steps to reproduce
Minimal, needs no Connect server; it shows only the precedence:
D=$(mktemp -d)
echo '{"serverUrl":"https://example.invalid"}' > "$D/config.json"
(unset BB_CLI; BB_DATA_DIR="$D" BB_SERVER_URL=http://127.0.0.1:59999 bb --help | grep 'BB_SERVER_URL:')
rm "$D/config.json"
(unset BB_CLI; BB_DATA_DIR="$D" BB_SERVER_URL=http://127.0.0.1:59999 bb --help | grep 'BB_SERVER_URL:')
rm -rf "$D"On a real affected machine:
- Move a desktop-hosted bb server to bb Connect, so the old desktop becomes a remote host whose
~/.bb/config.jsoncontainsserverUrl: https://<handle>.getbb.appandserverHeaderswith the machine credential. - Start any agent thread on that machine and have it run
bb thread show <any-thread-id> --json.
Expected vs actual
Minimal repro, actual:
BB_SERVER_URL: https://example.invalid # config.json present: the explicit env var is ignored
BB_SERVER_URL: http://127.0.0.1:59999 # config.json absent: the env var is used
Expected: the explicitly set BB_SERVER_URL is used in both cases.
Affected machine, actual, from an agent thread whose env has BB_SERVER_URL=http://127.0.0.1:59089 (the daemon's machine-auth proxy):
$ bb thread show thr_… --json
Error: HTTP 401: Unauthorized
{"ok": false, "error": {"code": "http_401", "message": "HTTP 401: Unauthorized"}}
$ bb --help | grep BB_SERVER_URL
BB_SERVER_URL: https://<handle>.getbb.app
With NODE_DEBUG=net, the CLI connects directly to the Connect hostname on port 443, and never to the loopback proxy.
Expected: the CLI uses the daemon-provided proxy and the command succeeds. The proxy itself works: curl "$BB_SERVER_URL/api/v1/threads/thr_…" returns 200 application/json, and "$BB_CLI" thread show thr_… --json, which bypasses the launcher, succeeds.
Evidence
- The launcher gives
config.serverUrlpriority overenv.BB_SERVER_URL:packages/bb-app/src/launcher.ts#L980-L987, applied to the CLI env at#L1389. - The launcher turns
serverHeadersintoBB_SERVER_HEADERS(#L996-L1014), but the CLI's direct requests to the Connect URL still return 401, so the credential doesn't reach them. - The daemon hands threads the authenticated loopback proxy as
BB_SERVER_URL(apps/host-daemon/src/start-host-daemon.ts#L135,apps/host-daemon/src/runtime-shell-env.ts#L413). - Through the proxy:
/api/v1/threads/:id,/api/v1/projects, and/api/v1/hostsreturn 200, while/healthreturns 401 (the Connect sign-in page). - Likely introduced with server migration (Add experimental server migration between machines #3783) and moving a desktop-hosted server away (Install the machine service when a desktop-hosted server moves away #4175), which leave
serverUrlin the old desktop'sconfig.json.
What you ruled out
- Not a stale or expired machine credential: the daemon's proxy, which uses the same
serverHeaders, authenticates fine. - Not shell configuration: no
BB_SERVER_URLin shell profiles, and~/.local/bin/bbonly execs the installed launcher. - Still present at
0.43.5-nightly.35773768107.1(minimal repro) and inmainatdea024ee6(code above). - No duplicate found in open or closed issues.
Suggested priority and effort
Every CLI call from every agent on an affected machine fails, so agents can't coordinate, report back, or open terminals. The workaround is to invoke "$BB_CLI" directly. Small fix: prefer an explicitly set BB_SERVER_URL over config.serverUrl in resolveServerUrl, or at least when the daemon provides it, plus a regression test. Terminals the user opens themselves don't set BB_SERVER_URL, so they keep resolving to config.serverUrl.
Checks
- I reproduced this on the latest release or on
main, or I say above that I could not. - I searched open and closed issues for the same problem.
- If an agent wrote this, the body ends with
> AGENT GENERATEDand links the thread or report.
Found while coordinating agent workers on the affected machine, in bb thread thr_ixu6r7h84m.
AGENT GENERATED
Activity
bb-slop-cop commentedon Sep 24, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotClassification: Bug · Priority: Medium · Effort: Low. Preserved
bug,remote, andcli; addedpartial-repro.Reproduction report: PARTIALLY REPRODUCED, high confidence in the URL-selection cause. A focused regression fails in two clean checkouts of
origin/main: saved configuration replaces the injected thread proxy URL. The CLI transport also does not forwardBB_SERVER_HEADERS; live Connect 401s remain unverified.No PR: an existing passing test explicitly requires config-over-environment precedence, so changing that policy exceeds the automatic simple-fix gate.
akrupa-appto commentedon Sep 29, 2026
still hitting this on bb desktop 0.44.0 after a server move to bb connect. it's the plain terminal case from #4277: on the old machine,
bb statuslooks fine but any real call (bb project list,bb plugin list) returns 401, because the cli goes straight tohttps://<handle>.getbb.appwithout the machine credential. settingBB_SERVER_URLto the daemon's loopback proxy doesn't help either, configserverUrlwins.this issue got closed but #4277 is still open, so it's not fixed in a release yet. workaround for now is running
bbover ssh on the server machine.timurkhakhalev commentedon Oct 14, 2026
Additional reproduction: the remote CLI problem remains with BB 0.46.0 after moving a server from macOS to Linux, with the former desktop enrolled as an execution machine.
There is also a desktop bundled-CLI entry point that needs coverage independently of the bb-app launcher:
bbcommand resolves directly to the installed package'shost-daemon/dist/bb, bypassingpackages/bb-app/src/launcher.ts.BB_SERVER_URLunset, this CLI targets the defaulthttp://127.0.0.1:38886, although the machine's saved configuration points at the moved server.BB_SERVER_URLexplicitly set to the public Connect endpoint, an API call returns HTTP 401. Supplying the saved headers asBB_SERVER_HEADERSdoes not authenticate this bundled CLI either.The current bundled CLI reads its server URL from the environment and does not load saved
serverUrl/serverHeaders; its transport does not attachBB_SERVER_HEADERS. Thus #4277 addresses the packaged launcher's URL precedence and adds environment-header support, but its launcher configuration resolution is bypassed by this desktop entry point. Please include a regression check for an ordinary terminal using the existing desktop-provided command after a server move, with neither connection variable supplied by the user.The daemon-provided proxy was used only as a diagnostic control, not installed as a replacement command. No private addresses, identifiers, absolute installation paths, or credentials are included here.
salemsayed commentedon Nov 20, 2026
@SawyerHood a remaining path for this closed issue, still on
mainat fab8266: the packaged launcher still prefersconfig.jsonserverUrlover the caller'sBB_SERVER_URL(launcher.ts#L1053-L1060, applied at #L1456-L1464 forrunBbCli'smanagedmode).Agent threads avoid it because the daemon puts its own CLI first on PATH. But on a Connect machine whose login profile prepends
~/.local/bin(here an installer addedexport PATH="$HOME/.local/bin:$PATH"to~/.bash_profile), bb terminals,--run-onscript automations and threads on that machine reach the machine shim first. The shim runs the launcher, so every plugin command fails:Minimal precedence repro, with no Connect server needed:
#4277 and #5486 carried the fix and were closed by the two-week rule, not on review. The shim staleness that makes this reachable is filed separately in #7897.