fix(buildlog): bump coder/coder to v2.33.2 to send agent token via header#170
Merged
deansheather merged 2 commits intomainfrom May 10, 2026
Merged
fix(buildlog): bump coder/coder to v2.33.2 to send agent token via header#170deansheather merged 2 commits intomainfrom
deansheather merged 2 commits intomainfrom
Conversation
…ader The buildlog client was logging '401: coder_session_token must be provided' on a tight retry loop because agentsdk's connectRPCVersion in v2.24.4 authenticated the WebSocket upgrade via http.Client.Jar, which the coder/websocket client silently ignores during the upgrade. Upstream v2.33.2 switched to passing the token via HTTPHeader on websocket.DialOptions, which coder/websocket does honor. Changes: - Bump github.com/coder/coder/v2 from v2.24.4 to v2.33.2. - Adopt the new agentsdk.New(serverURL, SessionTokenSetup, ...) signature by passing agentsdk.WithFixedToken(token); SetSessionToken is gone. - Migrate cdr.dev/slog -> cdr.dev/slog/v3 across the repo (agentsdk now uses v3, and the buildlog package passes the logger through to agentsdk.NewLogSender). - Mirror the relevant replace directives from coder/coder v2.33.2's go.mod (tailscale, wireguard-go, gvisor) so the build resolves. - Pin docker/cli to v27.4.1 via replace. docker/cli v29 (pulled in transitively by coder) imports the new moby/moby/client v0 module, which conflicts with the legacy moby/moby +incompatible module that ory/dockertest still drags in. v27.4.1 is the version dockertest itself requires and avoids the ambiguous import.
The official v1.64.8 pre-built binary is built with Go 1.24 and refuses to load a config when go.mod's go directive is >= 1.25. The coder/coder v2.33.2 bump pushed envbox's go.mod to go 1.25.9, breaking lint. Use install-mode: goinstall on golangci-lint-action so the runner builds the same v1.64.8 from source with the Go version we installed (now bumped to ~1.25). Other jobs are left on ~1.24 because Go's toolchain directive auto-downloads a matching toolchain at build time; golangci-lint does not use that mechanism.
ethanndickson
approved these changes
May 10, 2026
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.
Problem
When envbox starts in a Coder workspace pod, the buildlog client logs this on a tight retry loop:
The workspace still comes up (the call site at
cli/docker.go:199deliberately doesn't fail startup on buildlog errors), but no envbox build logs are pushed and the error spam confuses users debugging real workspace problems.Root cause
Envbox was pinned to
github.com/coder/coder/v2 v2.24.4. In that version,agentsdk.connectRPCVersionauthenticates the WebSocket upgrade via a cookie jar:The
coder/websocketpackage does not honorhttp.Client.Jarduring the upgrade — cookies from the jar are silently dropped, so the upgrade request reaches the server with no auth and the agent-token middleware returns 401.Mainline
coder/coderalready fixed this —connectRPCVersionnow passes the token viaHTTPHeader: http.Header{codersdk.SessionTokenHeader: ...}in thewebsocket.DialOptions, whichcoder/websocketdoes honor. Verified inv2.33.2atcodersdk/agentsdk/agentsdk.go:349-350.Changes
Bump
github.com/coder/coder/v2from v2.24.4 → v2.33.2. This is past the SessionTokenProvider refactor (1354d84) and the functional-args refactor (5c2b9a5), both of which are required soagentsdkusesHTTPHeaderfor the upgrade.buildlog/coder.go: adopt the newagentsdk.New(serverURL, SessionTokenSetup, ...)signature:Migrate
cdr.dev/slog→cdr.dev/slog/v3across the repo (12 files). Required because the newagentsdk.NewLogSendertakes acdr.dev/slog/v3.Logger, andbuildlog/coder.gopasses its logger straight through.Mirror coder/coder's
replacedirectives fortailscale.com,github.com/tailscale/wireguard-go, andgvisor.devso the v2.33.2 build resolves cleanly.Pin
github.com/docker/clito v27.4.1 viareplace. docker/cli v29 (pulled in transitively by coder) imports the newgithub.com/moby/moby/client v0.3.0module. The legacygithub.com/moby/moby +incompatiblemodule thatory/dockerteststill drags in also exposes the sameclientpackage, and Go cannot disambiguate when the parent module is+incompatible(nogo.mod). v27.4.1 is the versiondockertest v3.12.0itself requires and itscli/compose/loaderdoesn't importmoby/moby/client, so the conflict goes away. Rationale is documented inline ingo.mod.Acceptance criteria
go.modgithub.com/coder/coder/v2bumped to a version whereagentsdk.connectRPCVersionusesHTTPHeaderfor the session token (v2.33.2).buildlog/coder.goupdated for the newagentsdk.Newsignature.go mod tidyclean.go build ./...passes.go vet ./...— no new warnings (the two pre-existingcli/docker.gocancel/leak warnings are unchanged frommain).go test ./...— all unit tests pass.CODER_AGENT_TOKENandCODER_AGENT_URLset against a real Coder deployment. The buildlog client should NOT logconnect err … coder_session_token must be providedon the retry loop; it should connect successfully (or, on a real network error, surface a more accurate error). Marking this as a draft so a maintainer can sanity-check the dep bump scope before we run that.CODER_TEST_INTEGRATION=1 make test-integration) — not run locally because perAGENTS.mdit requires a VM/physical machine and Docker socket access not available in my sandbox. Will rely on CI.Out of scope
--no-startup-logflag.coder/coderrepo concern, already fixed upstream).