Files
coder/enterprise/coderd/x/chatd
Michael Suchacz 8b6f2c656c refactor(enterprise/coderd/x/chatd): remove the relay dialer's DialerFn bypass (#30920)
Removes `StreamPartsDialerConfig.DialerFn`, which replaced the whole
relay dial when set, and `TestStreamPartsDialerUsesConfiguredDialer`
with its `fakePartsSession`, the only code that set it. Production
builds the dialer in `enterprise/coderd/coderd.go` from the replica
resolver, HTTP client, and replica ID, and never sets `DialerFn`.

## Why it is safe

`git grep DialerFn` finds nothing after this change. The deleted test
handed its input to its own function and got its own fake session back,
so it never reached `dialRelayParts`. Its checks already run against the
real dial in `TestStreamPartsDialerDialsPartsEndpoint`, which dials a
WebSocket served by `httptest`. Each mutant below breaks one of those
checks in `dialRelayParts`, and the remaining test fails on each:

| Check of the deleted test | Real-dial check | Mutant | Result |
|---|---|---|---|
| chat ID reaches the dial | request path | `buildRelayURL(address,
uuid.Nil)` | fails |
| worker ID reaches the dial | resolver argument |
`ResolveReplicaAddress(ctx, uuid.Nil)` | fails |
| session token reaches the dial | `Coder-Session-Token` header |
`extractSessionToken(nil)` | fails |
| the dial returns the session | `require.NotNil(session)` | `return
nil, nil` | fails |

`TestStreamPartsDialerClassifiesHTTPFailures` and
`TestRelayDialErrorIsUnrecoverable` are unchanged.

## Review focus

`StreamPartsDialerConfig` is exported, but the package sits under `x/`
and its only importer is `enterprise/coderd`.

## Validation

- `go test ./enterprise/coderd/x/chatd/ -count=1 -race`: pass, before
and after.
- Mutants: `go test -overlay=<mutant> ./enterprise/coderd/x/chatd/ -run
'TestStreamPartsDialer|TestRelayDialError'` fails
`TestStreamPartsDialerDialsPartsEndpoint` for each row above. A copy
with a syntax error fails to build, which shows the overlay applies.
- `golangci-lint run ./enterprise/coderd/x/chatd/...`: 0 issues. The
pre-commit hook (`make pre-commit`: gen, fmt, lint, slim build) passed.

> Xum, an AI agent, opened this PR for @ibetitsmike and wrote this
description.
2026-10-27 10:14:02 +01:00
..