Repository navigation
Bug sweep 2: auth storage/refresh and MCP session fixes - #377
Merged
Merged
Conversation
… plaintext tokens - auth login stores credentials exclusively: after storing in one store it removes credentials from the other, so the new login is the one used (ResolveAuth prefers the keyring). Previously a keyring login followed by `login --insecure-storage` kept using the keyring org. - auth logout deletes from both stores, so logging out can't make stale plaintext credentials active. - Expired bearer tokens in the plaintext store are refreshed like keyring ones instead of failing immediately with ErrAuthExpired (headless Linux/containers without a keyring). - Keep the current refresh token when the refresh response has none (CLI and locald refresh paths). Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The remote MCP session, and the credentials captured in its transport, were created once and reused until the process exited. After `auth logout` + `auth login` as another org, AI-agent tool calls kept executing as the previous org (and bearer tokens went stale). Session() now resolves auth on every call and recreates the session when the credentials differ from those it was created with. Also don't panic on a remote error result with empty or non-text content. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`signadot mcp` waited for a successful fetch of the hosted MCP's /meta before serving stdio, retrying every 30s forever. Offline, behind a proxy, or during a hosted-MCP outage it never answered `initialize` (not even local tools like get_authentication_status) and never exited after the client left. Now it waits only for the first fetch attempt; remote tools are added (tools/list_changed) once a later fetch succeeds. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Sep 29, 2026
davixcky
approved these changes
Sep 30, 2026
davixcky
left a comment
Contributor
There was a problem hiding this comment.
LGTM. I built it locally (merged with the rest of the sweep) and compared it with main against staging. With mcp_url pointing at a dead port, signadot mcp on main never answers initialize; this branch answers in under 2s.
Non-blocking nits:
- A token refresh now rebuilds the MCP session (
internal/mcp/remote/remote.go). The session key includesBearerToken, so every refresh counts as a credential change and closes the old session, even while aCallToolon it is still running. The retry intools.gocan then run a non-idempotent call (like a sandbox create) twice. Maybe haveauthTransportread the current headers on each request, and key the session only on org plus user or API key. - Closing the old session can hang tool calls and leaks a connection (
remote.go:138). It runs underr.mu, and the go-sdk'sClosesends a DELETE with no timeout, so a remote that hangs blocks every tool call. It also drops the response body unclosed. Maybe close it outside the lock, in a goroutine. StoreExclusiveignores errors deleting the other store (internal/auth/storage.go:75). If deleting from the keyring fails, the old keyring login still wins. Maybe check it the wayDeleteAlldoes.- The plaintext credentials file is rewritten non-atomically, and now more often. #379 fixes this, so the two PRs need to land together.
- No tests for the empty-error-result panic fix or the locald refresh-token change.
Brings in origin/main via the updated base. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in the --attach and locald address fixes from #376's review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Brings in origin/main via the updated base. Co-Authored-By: Claude Opus 5.5 <[email protected]>
scott-cotton
added a commit
that referenced
this pull request
Oct 2, 2026
Brings in #377, merged into the base. Co-Authored-By: Claude Opus 5.5 <[email protected]>
scott-cotton
added a commit
that referenced
this pull request
Oct 2, 2026
Fourth batch of CLI bug-sweep fixes (ENG-1248). **Stacked on #376.** It is independent of #377 and #378, and merges cleanly with both. There is one commit per fix; review only the 9 commits here. ## Commits - **`fix(artifact)`**: download to a temp file and rename it into place on success. Before, `artifact download -j wrongjob report.xml` emptied an existing `report.xml` on a 404/401, and failed downloads left partial files. The 4-minute timeout now only limits how long the download takes to start; before, it covered the whole body, so any artifact taking longer than 4 minutes to download failed. - **`fix(sandbox)` get-files**: with the default output directory, `--no-clobber` no longer deletes the directory, and the local edits in it, before the check. - **`fix(sandbox)` apply**: no panic on a file without `spec`, which now returns an error. No panic when `--wait` fails before any successful GET; the applied sandbox is printed instead. - **`fix(secret)`**: the server's update replaces the description (confirmed in `sandboxes/internal/control/secret/update.go` and `appdb.UpdateSecret`), so `secret update NAME --value-file f` wiped it. The CLI now sends the current description unless `--description` is given; an explicit empty value still clears it. With `-f`, the file is still the whole secret. - **`fix(devbox)`**: create `~/.signadot` before `devbox register`. Before, when auth came only from the environment, the devbox was registered on the server and then saving its ID failed with ENOENT. - **`fix(poll)`**: `Readiness.Stop` racing a fatal error could panic with "close of closed channel", e.g. on Ctrl-C during `local override`, before the undo ran, leaving the override middleware on a shared sandbox. `done` is now closed via `sync.Once`. - **`fix(override)`**: the override log server now listens on loopback only. It listened on all interfaces, so anyone on the network could POST `/api/logs` and print spoofed entries to the user's terminal. - **`fix(auth)`**: plaintext credentials are written atomically (temp file + rename), and a file that fails to parse is reported instead of deleted. Before, a read concurrent with login or token refresh could see a partial file and delete the fresh credentials. - **`fix(bug)`**: `signadot bug` printed only the API config, because the embedded `*config.API`'s `MarshalJSON` was promoted. It dropped `BuildInfo` and `Error`, which are what the command is for. The error was also an interface, which marshals as `{}`. **Output shape change:** the API config is now nested under `config`. ## Testing - Each fix has a test. The ones for the artifact download, `sandbox apply` (missing spec), devbox, `poll` (reproduces "close of closed channel") and plaintext credentials were checked to fail without their fixes. Tests use fake API servers where needed. - `go vet ./...` and `go test ./...` pass; `-race` passes for `internal/auth` and `internal/poll`. Refs ENG-1248. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
scott-cotton
added a commit
that referenced
this pull request
Oct 2, 2026
Third batch of CLI bug-sweep fixes (ENG-1248), for `local connect`. **Stacked on #376** (independent of #377); review only the 4 commits here. Design invariants (see the triage comment on ENG-1248): at most one connect per machine, enforced by the locald pidfiles; disconnect has deliberately no deadline, since giving up part way could leave the machine's networking corrupted. ## Commits - **`fix(local): refuse connect when either local daemon is running`**: the pre-check only looked at the pidfile for the mode being started. With an unprivileged connect to cluster A running, a privileged `local connect --cluster B` started a root manager. Its sandbox-manager child failed to take the lock, and the root manager then monitored, and wired root networking to, A's sandbox manager. Connect still exited 0. - **`fix(locald): don't hang root manager shutdown after sbmgr monitor exits`**: if the sandbox manager command couldn't be formulated (e.g. the binary was moved or upgraded while connected), `sbmgrMonitor.run` returned without closing `doneAck`. `stop()` then blocked forever and disconnect never restored hosts, routes/pf or the resolver. - **`fix(local): report what disconnect is waiting on`**: no deadline added. After 5s, then every 30s, disconnect prints how long it has waited, the last shutdown error and the pidfiles/PIDs it is waiting on. Previously it retried silently forever, e.g. on a stale pidfile whose PID was reused after a hard power-off (`IsPIDRunning` treats EPERM as running). Proper staleness detection belongs in libconnect `processes`. - **`fix(locald): handle a missing tunnel API client in the sandbox manager`**: `GetResourceOutputs` (`sandbox get-env`/`get-files`) before the link was healthy called a nil client and crashed the sandbox manager; it now returns `Unavailable`. When the link never became healthy, the sandboxes watcher panicked on the nil client before the devbox session was released; the watcher now doesn't start without a client. The client is now guarded by the watcher mutex. ## Testing - New tests: either-pidfile pre-check, `stop()` after a fatal `run()` exit, disconnect wait report, and a nil tunnel client (GetResourceOutputs and watcher). The `doneAck` and tunnel-client tests fail without their fixes (timeout / nil-pointer panic). - `go vet ./...` and `go test ./...` pass; `-race` passes for `internal/locald/...` and `internal/command/local`. - Not yet run against a real cluster. Refs ENG-1248. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
scott-cotton
added a commit
that referenced
this pull request
Oct 2, 2026
Fifth batch of CLI bug-sweep fixes (ENG-1248), for plans. **Stacked on #376.** It is independent of #377, #378 and #379, and merges cleanly with each. There is one commit per fix; review only the 5 commits here. ## Commits - **`fix(plan): resume live plan logs`**: `plan run --attach` and `plan x logs -f` opened the live stream once and discarded its errors. That caused three problems: - A stream requested before dispatch got a 404 (`execution not yet dispatched to a runner`) and the run showed no logs. - After the server's 5-minute idle cut (`planexecution/logproxy.go`, e.g. a silent step), all later logs were lost. - `--attach` cancelled the stream as soon as a terminal phase was seen, dropping trailing lines. The new `planexec.FollowLiveLogs` reconnects from the last cursor on a 404 before the execution finishes, on 5xx, and on connection/SSE errors. It stops when the stream ends or the execution is finished (the runner no longer holds live logs). `--attach` now gives the stream up to 10s after the execution finishes to deliver the rest. - **`fix(plan): don't truncate --output-dir exports`**: the export used go-openapi's 30s default request timeout, which covers the whole streamed body. Large or slow outputs were truncated, the remaining outputs skipped, and the run still exited 0 with only a warning. Downloads now have no request timeout (the command's context bounds them) and are written atomically. A failed export makes `plan run` exit non-zero after the result is reported. - **`fix(plan): allow compile/recompile to take longer than 30s`**: the server compiles synchronously with an LLM, bounded only by the request context. After 30s the CLI hit its deadline, the server cancelled the compile, and no plan was created. The timeout is now 5 minutes. - **`fix(planexec): dedup step outputs`**: plan outputs were keyed by `<step>/<plan output name>` instead of `<step>/<StepRef.OutputName>`. `plan x outputs` and `get-output --all` listed referenced step outputs twice when the names differed, and hid unrelated step outputs that happened to share the plan output's name. - **`fix(plan): send --param values of string-typed params as strings`**: `python_version=3.10` was sent as a JSON number and reached the plan as `3.1`. If the plan declares the param's JSON Schema `type: string`, the value is now sent as given. Untyped params keep the existing JSON inference, so an untyped `3.10` is still sent as a number; plan authors can type the param to avoid that. ## Testing - `FollowLiveLogs` is tested against a fake server: 404 before dispatch, then a stream cut by an SSE error, then a resume, checking the output and the cursors sent. A separate test checks that it stops with the error once the execution is finished. There are also tests for export (partial failure, no leftover files), output dedup (fails without the fix) and string-schema params. - `go vet ./...` and `go test ./...` pass; `-race` passes for `plan` and `planexec`. - Not yet run against a real plan execution. Refs ENG-1248. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Second batch of CLI bug-sweep fixes (ENG-1248). Stacked on #376 — base is
scott/bug-sweep; review only the 3 commits here.Commits
fix(auth)— keep keyring and plaintext credentials consistent:auth loginstores exclusively (auth.StoreExclusive): after writing one store it removes the other, so the new login is actually used (ResolveAuthprefers the keyring). Before: keyring login as org A, thenlogin --insecure-storageas org B → success printed, org A still used.auth logoutdeletes from both stores (auth.DeleteAll). Before: logout removed the keyring entry and silently activated stale plaintext credentials.ErrAuthExpired(headless Linux / containers without a keyring had to re-login every token lifetime).fix(mcp)session — the remote MCP session (and credentials captured in its transport) was created once per process. After re-login as another org, agent tool calls (create/update sandbox, …) kept executing as the old org.Session()now resolves auth each call and recreates the session when credentials change. Also: no panic on a remote error result with empty/non-text content.fix(mcp)startup —signadot mcpblocked serving stdio until a successful/metafetch (retried every 30s forever), so offline / behind a proxy / during a hosted-MCP outage it never answeredinitialize. Now it waits only for the first attempt; remote tools arrive viatools/list_changedonce a later fetch succeeds.Not addressed (still open in ENG-1248)
api_url/--config) — design question.Testing
HOME: login/logout store consistency, plaintext refresh (fake refresh endpoint), MCP session recreation on re-login (fake streamable MCP server), first-fetch-on-failure. Each verified failing without its fix.go vet ./...,go test ./...clean;-raceclean forauth,config,mcp/....Refs ENG-1248.
🤖 Generated with Claude Code