Repository navigation
Bug sweep 4: data loss and crashes in everyday commands - #379
Conversation
…t large ones - Download to a temp file in the output directory and rename it into place on success. Previously the output file was truncated before the request, so e.g. `artifact download -j wrongjob report.xml` zeroed an existing report.xml on a 404/401, and failures left partial files. - The 4 minute timeout covered the whole streamed body, so artifacts taking longer to download always failed. It now only bounds the time until the download starts. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…default dir With the default output directory, get-files removed the directory before the --no-clobber check, so local edits were deleted anyway. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- A sandbox file without `spec` (typo, empty, templated away) panicked on req.Spec.Cluster; it now returns an error. - If --wait failed before any successful GET (cancel, API down for the whole timeout), the nil sandbox was passed to writeOutput and panicked; the applied sandbox is output instead. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…iven The server's update replaces the description, so `secret update NAME --value-file f` without --description wiped the stored one. The CLI now sends the current description unless --description was given (an explicit empty value still clears it). With -f the file remains the whole secret. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`devbox register` wrote ~/.signadot/.devbox-id without creating the directory, so with auth only from the environment the devbox was registered server-side and then saving its ID failed with ENOENT. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
run (on a fatal error) and Stop both did an unsynchronised check-then-close of done, so e.g. Ctrl-C during `local override` could panic with "close of closed channel" before the deferred undo, leaving the override middleware on the shared sandbox. Close done via sync.Once. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The log server listened on all interfaces although the sandbox forward delivers logs to localhost, so network peers could POST /api/logs and print spoofed entries or escape sequences to the user's terminal. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…on read errors Credentials were written with a non-atomic os.WriteFile, and a reader that failed to parse the file deleted it. A concurrent read during login or token refresh (CLI, MCP server, locald) could therefore see a partial file and delete freshly written credentials. Write via a temp file + rename, and report an unparsable file instead of deleting it. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
BugConfig embedded *config.API, whose MarshalJSON was promoted, so the
output was only the API config and dropped BuildInfo and Error, the CLI
version and init error the command exists to report (the error was
also an interface, marshalled as {}). Use named fields and a string
error.
Refs ENG-1248.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Risk: high. Left a non-blocking comment and did not approve: this PR changes auth credential persistence, secret updates, and multiple data-loss paths, which is above the medium approval threshold. Human review is needed; no reviewer assignment tool is available, so no reviewers were assigned.
Sent by Cursor Approval Agent: Pull Request Approver
Brings in origin/main via the updated base. Resolves the two places main's #362 (sandbox apply --dry-run) met this branch: - apply.go: both added a nil-spec check; keeps main's wording, "sandbox must specify a spec" (TestApplyMissingSpec checks only "spec"). - apply_test.go: both created the file; keeps main's dry-run tests and this branch's apply tests side by side, imports merged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Risk: high. Left a non-blocking comment and did not approve: this PR changes auth credential persistence, secret updates, and multiple data-loss paths, which is above the medium approval threshold. Human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: Pull Request Approver
davixcky
left a comment
There was a problem hiding this comment.
I built this locally, merged with the rest of the sweep (#376–#381), and compared it with main against staging. Most fixes work:
artifact download -j <missing job>over an existingreport.xmlnow keeps the file. Onmainit was emptied to 0 bytes.secret update NAME --value-file fnow keeps the description. Onmainit was wiped.sandbox applyon a file withoutspecreturnssandbox file must specify spec. Onmainit was a SIGSEGV.signadot bugnow includes build info.
Requesting changes for the artifact download regressions. writeFileAtomic creates a temp file next to the target and renames it into place. That breaks any -o that isn't a regular file in a directory you can write to. I tested with a real artifact from a job:
-o target |
main |
this PR |
|---|---|---|
| regular file | ✅ | ✅ |
/dev/stdout (piped) |
✅ works | ❌ open /dev/.stdout.tmp-…: permission denied, exit 1 |
symlink → real.xml |
✅ writes through the link | ❌ link replaced by a regular file; real.xml keeps its old contents |
new file under umask 077 |
600 |
644 (the fixed Chmod ignores the umask) |
Run as root (common in CI containers), the /dev/stdout case renames a regular file over the /dev/stdout symlink instead of failing. Suggested fix: Lstat the target, and if it exists and isn't a regular file, write to it directly as before. For a new file, skip the Chmod, or apply the umask.
Also, not blocking:
- A stalled download now hangs forever. The start timer is stopped on the first write and nothing replaces it. Calling
Reset(timeout)on every write would make it an idle timeout. - A corrupt plaintext credentials file blocks
auth logoutandauth status. Logout fails withcould not resolve auth: invalid credentials file …, so it can't clear the file. I confirmed this live. Maybe let logout delete the file on that error. There's also notmp.Sync()before the rename. - Mismatched hosts for the override log server. It now listens on
127.0.0.1, butToLocalinbuilder/sandbox_override.go:66is stilllocalhost:<port>, which breaks on hosts wherelocalhostresolves only to::1.
Brings in the --attach and locald address fixes from #376's review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Risk: high. Left a non-blocking comment and did not approve: this PR changes auth credential persistence, secret updates, and multiple data-loss paths, which is above the medium approval threshold. Human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: Pull Request Approver
40ec067 wrote the download to a temp file beside -o and renamed it over, which is not writing to -o: /dev/stdout failed (and as root was replaced by a regular file), a symlink was replaced rather than written through, and a new file ignored the umask. The output is now os.Create on the -o name, as on main, opened when the first byte arrives — so a request that fails before any data still leaves an existing file as it was, which is what the temp file was for. An empty artifact still makes an empty file. The start timeout is now an idle timeout, reset by every write, so a download that stalls partway is an error rather than a hang. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An unreadable plain-text credentials file is kept rather than deleted on read, but that made `auth logout` fail resolving it, so the one command that clears it could not. Logout now removes it. The file is also synced before it is renamed into place. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The override log server listens on 127.0.0.1, but the sandbox forward named localhost:<port>, which breaks where localhost resolves only to ::1. Refs ENG-1248. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Risk: high. Left a non-blocking comment and did not approve: this PR changes auth credential persistence, secret updates, and multiple data-loss paths, which is above the medium approval threshold. Human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: Pull Request Approver
Brings in origin/main via the updated base. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Risk: high. Left a non-blocking comment and did not approve: this PR changes auth credential persistence, secret updates, and multiple data-loss paths, which is above the medium approval threshold. Human review is needed and no reviewers were assigned.
Sent by Cursor Approval Agent: Pull Request Approver
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]>


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.xmlemptied an existingreport.xmlon 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-clobberno longer deletes the directory, and the local edits in it, before the check.fix(sandbox)apply: no panic on a file withoutspec, which now returns an error. No panic when--waitfails before any successful GET; the applied sandbox is printed instead.fix(secret): the server's update replaces the description (confirmed insandboxes/internal/control/secret/update.goandappdb.UpdateSecret), sosecret update NAME --value-file fwiped it. The CLI now sends the current description unless--descriptionis given; an explicit empty value still clears it. With-f, the file is still the whole secret.fix(devbox): create~/.signadotbeforedevbox 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.Stopracing a fatal error could panic with "close of closed channel", e.g. on Ctrl-C duringlocal override, before the undo ran, leaving the override middleware on a shared sandbox.doneis now closed viasync.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/logsand 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 bugprinted only the API config, because the embedded*config.API'sMarshalJSONwas promoted. It droppedBuildInfoandError, 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 underconfig.Testing
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 ./...andgo test ./...pass;-racepasses forinternal/authandinternal/poll.Refs ENG-1248.
🤖 Generated with Claude Code