fix: treat a missing serve endpoint as a fatal dial error (#27864)

Adds 404 as a terminal error for establishing DRPC connection.

A standalone AI Gateway pointed at a coderd that does not expose
`/api/v2/ai-gateway/serve` gets a 404, which the connect loop classified
as transient and retried forever. Redialing cannot fix a missing
endpoint.
404 now is treated as terminal handshake failure. `--url` is expected to
point directly at coderd, so a 404 from an intermediary is not
distinguished.

Refs https://linear.app/codercom/issue/AIGOV-320/write-connection-tests

---

Generated with Coder Agents.
This commit is contained in:
Paweł Banaszewski
2026-08-19 13:19:20 +02:00
committed by GitHub
parent 8405bbb26c
commit 63641b98c8
3 changed files with 92 additions and 2 deletions
+7
View File
@@ -310,6 +310,13 @@ The standalone Gateway image does not need to match the `coderd` image version e
The components can connect when their AI Gateway API versions are compatible, and `coderd` checks compatibility whenever a Gateway replica connects.
A replica may run at the same API version as `coderd` or an earlier minor version of the same major version, but never a newer one.
The Gateway treats certain handshake failures from `/api/v2/ai-gateway/serve` as fatal and exits rather than retrying:
- HTTP 400: incompatible API version.
- HTTP 401: invalid Gateway key.
- HTTP 403: missing entitlement.
- HTTP 404: endpoint not found. `coderd` may be too old and not expose `/serve` endpoint.
Sequence changes that move both components:
- To upgrade, upgrade `coderd` first, then roll out the standalone Gateway release.