Skip to content

Provisioning hooks (.bb-env-setup.sh / .bb-env-teardown.sh) cannot reach the bb server after a server move #7192

Open

Description

@apshendev

bb 0.48.1, Windows 11, a machine connected via bb Connect after a server move (~/.bb/server-moved.json, mode: connect).

Our .bb-env-setup.sh creates a paired worktree on another bb machine with bb terminal create --machine <name>, and .bb-env-teardown.sh removes it the same way. Both hooks receive a sanitized environment: NODE_ENV and every BB_* are removed, as documented in bb guide environments. Because of that:

  • without BB_SERVER_URL, the CLI targets the default http://127.0.0.1:38886 and gets HTTP 410 server_moved: This bb server moved to <host> (https://<handle>.getbb.app);
  • with BB_SERVER_URL=https://<handle>.getbb.app it gets HTTP 401, because the CLI does not send the machine header (x-bb-connect-machine); only the daemon reads BB_SERVER_HEADERS;
  • inside threads, BB_SERVER_URL points to the daemon's machine auth proxy (http://127.0.0.1:<random port>), and the CLI works through it even with an otherwise empty environment, but a hook has no documented way to find that port.

Related: #4243 (closed) fixed the same 401 cause for agent threads, where BB_SERVER_URL is present. Provisioning hooks have no BB_SERVER_URL at all, so they are not covered by that fix.

Request: give provisioning hooks a documented way to call the bb CLI on the machine's behalf. For example:

  • pass BB_SERVER_URL (the machine auth proxy) to .bb-env-setup.sh / .bb-env-teardown.sh; or
  • make the CLI outside a thread follow the server move: use serverUrl and serverHeaders from ~/.bb/config.json, or the proxy URL from a runtime file.

Workarounds we use now: the setup hook leaves a marker file, and a Claude Code SessionStart hook in the first thread session (which has BB_SERVER_URL) starts the remote setup in the background. The teardown hook reaches the other machine over our own ssh tunnel instead of bb terminal.

Activity

  1. added theissue type on Nov 6, 2026
  2. added
    workspaces
    cli
    connect
    partial-repro
    on Nov 6, 2026
  3. bb-slop-cop commented on Nov 6, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Medium. Applied labels: workspaces, cli, connect, partial-repro.
    • Reproduction report: PARTIALLY REPRODUCED, with high root-cause confidence.
    • Root cause: lifecycle sanitization removes the machine-auth proxy endpoint, so the CLI falls back to loopback; supplying a direct URL does not supply machine authentication.
    • Evidence: two clean trusted-main checkouts each show two endpoint-regression failures and two passing real CLI/proxy controls. Existing relevant tests: 29 passed, 1 skipped. Native Windows and the hosted server-move workflow remain unverified.
    • No PR: changing authentication-context propagation into repository hooks exceeds the simple-fix safety rules.

    AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliconnectpartial-reproworkspaces

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions