Skip to content

Commit f20b552

Browse files
authored
🤖 deps: bump Coder SDK to v2.37.3 (#163)
## Summary Bump `github.com/coder/coder/v2` from v2.35.8 to v2.37.3 and re-vendor. The bump also moves `github.com/modelcontextprotocol/go-sdk` from v1.4.1 to v1.7.0. That SDK no longer applies cross-origin protection by default, so the MCP HTTP handler now wraps itself with `net/http`'s `CrossOriginProtection` to keep the existing behavior. The bump also changes one answer of the workspace start and stop subresources (#187). This PR fixes that, so they behave as before (see the table below). Refs #150 Maintainer decision 2026-10-12: v2.37.3 ships as a stable-channel exception. ## Background The AI provider, chat model and MCP server APIs that the planned AI resources need live in Coder v2.37 (chats moved from `/api/experimental` to `/api/v2`). #150 and the AI CRDs (#154, #155, #156) need them. Version choice: every v2.37.x release is a Coder *mainline* release. The *stable* channel is still v2.36.6. #150 requires v2.37, so this takes the newest v2.37 patch, v2.37.3. Its changes over v2.37.2 are a tailnet panic fix, model catalog backports and `owner_id` on `CreateChatRequest`. None of them touch workspaces, templates or provisioners. E2E backend pin: CI keeps `ghcr.io/coder/coder:v2.37.2@sha256:6ea19b67…` (`.github/workflows/ci.yaml`). A v2.37.3 SDK against a v2.37.2 server is a patch-level skew inside one minor line. The existing identity and resourceVersion evidence is bound to 2.37.2, so the backend does not move in this PR. ## Implementation - `go get github.com/coder/coder/v2@v2.37.3`, `go mod tidy`, `go mod vendor`, on top of current `main` (rebased, `vendor/` regenerated, not hand-merged). The `go` directive (1.26.8) and all Kubernetes libraries (`k8s.io/*`, controller-runtime) are unchanged. Notable transitive moves: MCP go-sdk 1.4.1 → 1.7.0, prometheus `client_golang` 1.23.2 → 1.24.1, testify 1.11.1 → 1.12.0, `terraform-provider-coder` 2.18.0 → 2.19.0. The `go.mod` version moves are identical to the original (pre-rebase) commit. - `internal/app/mcpapp/http.go`: wrap the streamable HTTP handler with `http.NewCrossOriginProtection().Handler(...)`, which is the SDK's documented replacement for its deprecated option. The existing `cross origin`, `opaque origin`, `cross site fetch` and `cross origin service` cases in `TestHTTPTransportSecurity` fail without this wrap. - `internal/app/mcpapp/http_test.go`: `application/json; charset=utf-8` is now accepted, because the SDK matches the base media type. A charset parameter keeps the request non-simple for CORS, so browsers still preflight it. A new case pins the SDK's 4 MiB body limit (413). - `docs/how-to/mcp-server.md`: request-rules table updated to match. - `.github/workflows/ci.yaml`: add `vendor/github.com/coder/coder/v2/**` to the pre-queue `e2e` path filter (#113). Before this change, an SDK bump got only a skip notice in the PR's E2E job, even though the SDK carries every aggregated-API call to the backend. - `internal/aggregated/storage/workspace_transition.go`: `isUncertainStatus` now counts a 2xx status as uncertain (see the first table row). New cases in `TestWorkspaceTransitionUncertainPost` cover a 201 and a 200 proxy page. - CoderTemplateTest tests (no controller change): the fake Coder gets an `HTML` fault (a `text/html` body with any status). New cases pin a 200 and a 201 proxy page on create (`TestTemplateTestCreateResults`) and a 200 proxy page on the readiness read (`TestTemplateTestReadinessProxyPage`). ### SDK behavior changes that affect existing resources | Change | Evidence | Effect here | | --- | --- | --- | | A 2xx response whose body is not valid JSON (empty, HTML, malformed) now returns `*codersdk.Error` with the 2xx status. It used to be a plain decode error. `Error()` reads `invalid API response (status code N)`, `Message` reads `Received an HTML response instead of JSON from the Coder API.` (or the empty/invalid JSON variant), and `Unwrap` exposes the cause. | `codersdk/client.go:521`, `:538-571`, `:664-680`, `:743` | **Workspace start/stop (#187), fixed here.** `workspace_transition.go:156` re-reads Coder when the error is not a `*codersdk.Error` or has an uncertain status. A 2xx proxy page used to take that path. With the bump it fell through to `MapCoderError` and answered a definitive 500, although Coder had queued the build. `isUncertainStatus` now includes 2xx, so the answer is again the confirmed `Queued` result or the uncertain 504. **CoderTemplateTest (#194-#213), no classification change.** Every `coderStatus()` branch matches only specific 4xx codes (401, 404, 406, 409, 410, 412, 429, 400) or the 4xx range, so a 2xx `*codersdk.Error` takes the same branch as the old status-0 decode error: create stays `ConfirmingCreate` and never sends a second request (`codertemplatetest_create.go:59-93`). `createHadNoEffect` does not match 2xx, so the marker stays. The readiness and confirm reads answer `CoderUnavailable` and never treat the answer as 410 deletion (`codertemplatetest_readiness.go:36`, `codertemplatetest_confirm.go:44`, `:66`). The status message changes from the raw decode error to `Coder answered 2xx: Received an HTML response…`. It holds `Message` only, so `Detail` (content type, redirect URL) does not reach status. **Everything else, no change.** `MapCoderError` (`internal/aggregated/coder/errors.go`), `template_promote.go:181` (4xx only, else re-read), and the control plane and provisioner controllers branch on 4xx only, so 2xx falls through to the same InternalError or retry path as before. | | A JSON body with `Content-Type: text/html` is now an error. The old decoder ignored the header and decoded it. | `codersdk/client.go:544-547` | Coder never labels API JSON as HTML, so only a misconfigured proxy sees this. A CoderTemplateTest create then becomes uncertain and confirms the workspace by provenance instead of taking the answer. That is the fail-safe direction. | | `Template.AgentsAllowed` (new field). `UpdateTemplateMeta.AgentsAllowed` and `CreateTemplateRequest.AgentsAllowed` are `*bool,omitempty`. | `codersdk/templates.go:71`, `:288`; `codersdk/organizations.go:235` | `convert/template.go` never sets it, so the server keeps the current value on update and defaults it to true on create. This is the same as before, because the 2.37.2 server already applies those defaults. Not surfaced in the CR. CoderTemplateTest creates workspaces through the normal API as the operator user, not as a Coder Agent, so the flag does not gate it. | | `CreateWorkspaceBuildRequest.OnSuccess` (omitempty), `WorkspaceFilter.IncludeAgentMetadata`, `WorkspaceAgent.Metadata` (omitempty) | `codersdk/workspaces.go:142`, `:565`; `codersdk/workspaceagents.go:177` | Unset, so the wire requests are unchanged. That includes the CoderTemplateTest delete build (`codertemplatetest_delete.go:103`) and the start/stop builds. CoderTemplateTest readiness reads agent status and lifecycle only, never `Metadata`. | | Prebuilds: `PrebuildsSystemUserID` and the agent status, lifecycle, provisioner job status and transition constants | `codersdk/prebuilds.go:13` | Unchanged values. CoderTemplateTest provenance (`codertemplatetest_confirm.go:135`) still recognizes claimed prebuilds by this user ID. | | Entitlement comparison: a nil limit on a usage-period feature now means unlimited | `codersdk/deployment.go:438` | Only `agent_runtime_hours` is a usage-period feature. The control plane and provisioner read `external_provisioner_daemons`, `multiple_organizations` and `custom_roles`, which are unaffected. | | `License.Trial()` reads the `trial` claim (was misspelled `trail`). New reserved-provisioner-key helpers. | `codersdk/licenses.go:86`; `codersdk/provisionerdaemons.go:426` | Not called by coder-k8s. | | MCP go-sdk: cross-origin protection is off by default, `Content-Type` matches the base media type, and request bodies are limited to 4 MiB | `go-sdk/mcp/streamable.go:243`, `:388`, `:225` | Cross-origin protection restored by the wrap above. The other two are documented and tested. DNS-rebinding (loopback `Host`) protection is unchanged. | ## Validation On the pushed commit `48891a0` (tree `cffac8d`), rebased onto `main` `41e4acb` (#222: go1.26.9 and `golang.org/x/net` v0.60.0): actionlint, `make verify-vendor`, `make test`, `make test-integration`, `make build`, `make lint`, `make docs-check`, `GOFLAGS=-mod=vendor go tool govulncheck ./...` (the CI command: 0 called vulnerabilities) and `go test -race -count=1 ./internal/controller/...` all pass. Dependencies: I reset `go.mod` and `go.sum` to `main`, then ran `go get github.com/coder/coder/v2@v2.37.3 && go mod tidy && go mod vendor`. The `go` directive stays 1.26.9 and `x/net` stays v0.60.0. The `go.mod` and `go.sum` diffs against `main` are line-for-line identical to the diffs of the previous head (`522fd78` against `55e7f34`), so the SDK bump moves the same modules as before on top of the #222 baseline. The new `TestWorkspaceTransitionUncertainPost` rows fail on the v2.37.3 SDK without the `isUncertainStatus` fix (no confirming re-read). The 200 row also fails on `main` with the v2.35.8 SDK. That SDK already returned `*codersdk.Error` for a 200 on a POST that expects 201, so that gap predates this PR, and the fix also covers it. Known local-only failure: `hack/e2e-workspace-lifecycle_test.sh` (part of `make test-scripts`) times out locally in its `pass` scenario. It fails the same way on unmodified `main` on this host. The PR touches no `hack/` script. CI's run is authoritative. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
1 parent 41e4acb commit f20b552

258 files changed

Lines changed: 20652 additions & 4665 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/ci.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ jobs:
9191
- 'examples/cloudnativepg/**'
9292
- 'hack/e2e-workspace-lifecycle*.sh'
9393
- '.github/workflows/ci.yaml'
94+
# Coder SDK bumps change how every aggregated-API call reaches the backend.
95+
- 'vendor/github.com/coder/coder/v2/**'
9496
installer:
9597
- 'api/**/*.go'
9698
- 'config/crd/bases/**'

‎docs/how-to/mcp-server.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,17 @@ curl -fsS http://127.0.0.1:8090/readyz
7373

7474
## Request rules
7575

76-
The bearer token check runs first. After it, the MCP Go SDK (1.4.1) enforces these transport checks. They are protections, not authentication, and they can cause surprising errors:
76+
The bearer token check runs first. After it, the server and the MCP Go SDK (1.7.0) enforce these transport checks. They are protections, not authentication, and they can cause surprising errors:
7777

7878
| Rule | Error when broken |
7979
| --- | --- |
80+
| Cross-site POST requests (detected via `Origin` or `Sec-Fetch-Site`) are rejected. Clients that send neither header are allowed. | `403 Forbidden` |
8081
| Requests arriving on a loopback address must use a loopback `Host` (`localhost:8090`, `127.0.0.1:8090`). A reverse proxy that connects over loopback but keeps a Service or external hostname fails. | `403 Forbidden` |
81-
| POST requests must have exactly `Content-Type: application/json`. A missing header, form types, and `application/json; charset=utf-8` all fail. | `415 Unsupported Media Type` |
82-
| Cross-site POST requests (detected via `Origin` or `Sec-Fetch-Site`) are rejected. Clients that send neither header are allowed. | Rejected |
82+
| POST requests must use the `application/json` media type. Parameters such as `charset=utf-8` are allowed; a missing header and form types fail. | `415 Unsupported Media Type` |
83+
| Request bodies are limited to 4 MiB. | `413 Request Entity Too Large` |
8384

8485
Also note:
8586

8687
- JSON field names are case-sensitive. A key with an appended null character does not alias the original key.
8788
- Service names, session IDs, and other client-supplied headers are not credentials. Only the bearer token is.
88-
- Do not disable the SDK's localhost or cross-origin protections to work around routing problems.
89+
- Do not disable the localhost or cross-origin protections to work around routing problems.

‎go.mod‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ module github.com/coder/coder-k8s
33
go 1.26.9
44

55
require (
6-
github.com/coder/coder/v2 v2.35.8
6+
github.com/coder/coder/v2 v2.37.3
77
github.com/coder/websocket v1.8.14
88
github.com/google/cel-go v0.30.0
99
github.com/google/uuid v1.6.0
1010
github.com/lib/pq v1.10.9
11-
github.com/modelcontextprotocol/go-sdk v1.4.1
12-
github.com/stretchr/testify v1.11.1
11+
github.com/modelcontextprotocol/go-sdk v1.7.0
12+
github.com/stretchr/testify v1.12.0
1313
github.com/yuin/gopher-lua v1.1.2
1414
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da
1515
k8s.io/api v0.35.0
@@ -95,9 +95,10 @@ require (
9595
github.com/alingse/nilnesserr v0.2.0 // indirect
9696
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
9797
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
98+
github.com/apparentlymart/go-textseg/v17 v17.0.1 // indirect
9899
github.com/ashanbrown/forbidigo/v2 v2.3.0 // indirect
99100
github.com/ashanbrown/makezero/v2 v2.1.0 // indirect
100-
github.com/aws/aws-sdk-go-v2 v1.42.0 // indirect
101+
github.com/aws/aws-sdk-go-v2 v1.43.4 // indirect
101102
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
102103
github.com/aymerick/douceur v0.2.0 // indirect
103104
github.com/bahlo/generic-list-go v0.2.0 // indirect
@@ -130,8 +131,8 @@ require (
130131
github.com/clipperhouse/uax29/v2 v2.6.0 // indirect
131132
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 // indirect
132133
github.com/coder/serpent v0.15.0 // indirect
133-
github.com/coder/terraform-provider-coder/v2 v2.18.0 // indirect
134-
github.com/coreos/go-oidc/v3 v3.19.0 // indirect
134+
github.com/coder/terraform-provider-coder/v2 v2.19.0 // indirect
135+
github.com/coreos/go-oidc/v3 v3.20.0 // indirect
135136
github.com/coreos/go-semver v0.3.1 // indirect
136137
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
137138
github.com/curioswitch/go-reassign v0.3.0 // indirect
@@ -141,7 +142,7 @@ require (
141142
github.com/denis-tingaikin/go-header v0.5.0 // indirect
142143
github.com/dlclark/regexp2 v1.12.0 // indirect
143144
github.com/dustin/go-humanize v1.0.1 // indirect
144-
github.com/ebitengine/purego v0.10.1 // indirect
145+
github.com/ebitengine/purego v0.10.2 // indirect
145146
github.com/elastic/crd-ref-docs v0.3.0 // indirect
146147
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
147148
github.com/ettle/strcase v0.2.0 // indirect
@@ -196,7 +197,7 @@ require (
196197
github.com/google/btree v1.1.3 // indirect
197198
github.com/google/gnostic-models v0.7.0 // indirect
198199
github.com/google/go-cmp v0.7.0 // indirect
199-
github.com/google/jsonschema-go v0.4.2 // indirect
200+
github.com/google/jsonschema-go v0.4.3 // indirect
200201
github.com/google/pprof v0.0.0-20250820193118-f64d9cf942d6 // indirect
201202
github.com/gordonklaus/ineffassign v0.2.0 // indirect
202203
github.com/gorilla/css v1.0.1 // indirect
@@ -218,7 +219,7 @@ require (
218219
github.com/hashicorp/hcl/v2 v2.24.0 // indirect
219220
github.com/hashicorp/logutils v1.0.0 // indirect
220221
github.com/hashicorp/terraform-plugin-go v0.31.0 // indirect
221-
github.com/hashicorp/terraform-plugin-log v0.10.0 // indirect
222+
github.com/hashicorp/terraform-plugin-log v0.10.1-0.20260721164921-2f73dc013b2c // indirect
222223
github.com/hashicorp/terraform-plugin-sdk/v2 v2.40.1 // indirect
223224
github.com/hashicorp/yamux v0.1.2 // indirect
224225
github.com/hexops/gotextdiff v1.0.3 // indirect
@@ -234,7 +235,7 @@ require (
234235
github.com/karamaru-alpha/copyloopvar v1.2.2 // indirect
235236
github.com/kisielk/errcheck v1.9.0 // indirect
236237
github.com/kkHAIKE/contextcheck v1.1.6 // indirect
237-
github.com/klauspost/compress v1.18.7 // indirect
238+
github.com/klauspost/compress v1.19.1 // indirect
238239
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
239240
github.com/kulti/thelper v0.7.1 // indirect
240241
github.com/kunwardeep/paralleltest v1.0.15 // indirect
@@ -292,10 +293,10 @@ require (
292293
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
293294
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
294295
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
295-
github.com/prometheus/client_golang v1.23.2 // indirect
296+
github.com/prometheus/client_golang v1.24.1 // indirect
296297
github.com/prometheus/client_model v0.6.2 // indirect
297-
github.com/prometheus/common v0.69.0 // indirect
298-
github.com/prometheus/procfs v0.20.1 // indirect
298+
github.com/prometheus/common v0.70.1 // indirect
299+
github.com/prometheus/procfs v0.21.1 // indirect
299300
github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect
300301
github.com/quasilyte/go-ruleguard v0.4.5 // indirect
301302
github.com/quasilyte/go-ruleguard/dsl v0.3.23 // indirect
@@ -334,7 +335,7 @@ require (
334335
github.com/spf13/viper v1.16.0 // indirect
335336
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
336337
github.com/stbenjam/no-sprintf-host-port v0.3.1 // indirect
337-
github.com/stretchr/objx v0.5.2 // indirect
338+
github.com/stretchr/objx v0.5.3 // indirect
338339
github.com/subosito/gotenv v1.4.2 // indirect
339340
github.com/tetafro/godot v1.5.4 // indirect
340341
github.com/timakin/bodyclose v0.0.0-20241222091800-1db5c5ca4d67 // indirect
@@ -349,7 +350,7 @@ require (
349350
github.com/ultraware/whitespace v0.2.0 // indirect
350351
github.com/uudashr/gocognit v1.2.0 // indirect
351352
github.com/uudashr/iface v1.4.1 // indirect
352-
github.com/valyala/fasthttp v1.72.0 // indirect
353+
github.com/valyala/fasthttp v1.73.0 // indirect
353354
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
354355
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
355356
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
@@ -363,7 +364,7 @@ require (
363364
github.com/ykadowak/zerologlint v0.1.5 // indirect
364365
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
365366
github.com/yusufpapurcu/wmi v1.2.4 // indirect
366-
github.com/zclconf/go-cty v1.18.1 // indirect
367+
github.com/zclconf/go-cty v1.19.0 // indirect
367368
github.com/zeebo/errs v1.4.0 // indirect
368369
gitlab.com/bosi/decorder v0.4.2 // indirect
369370
go-simpler.org/musttag v0.14.0 // indirect
@@ -380,7 +381,7 @@ require (
380381
go.opentelemetry.io/collector/pdata v1.51.1-0.20260205185216-81bc641f26c0 // indirect
381382
go.opentelemetry.io/collector/pdata/pprofile v0.145.1-0.20260205185216-81bc641f26c0 // indirect
382383
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.69.0 // indirect
383-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.69.0 // indirect
384+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.70.0 // indirect
384385
go.opentelemetry.io/otel v1.45.0 // indirect
385386
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.45.0 // indirect
386387
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.45.0 // indirect
@@ -412,7 +413,7 @@ require (
412413
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
413414
google.golang.org/appengine v1.6.8 // indirect
414415
google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d // indirect
415-
google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d // indirect
416+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260807164820-c8921c73eeea // indirect
416417
google.golang.org/grpc v1.83.2 // indirect
417418
google.golang.org/protobuf v1.36.11 // indirect
418419
gopkg.in/DataDog/dd-trace-go.v1 v1.74.0 // indirect

0 commit comments

Comments
 (0)