Skip to content

fix: send coder User-Agent on all deployment requests - #180

Merged
untra merged 1 commit into
mainfrom
user-agent-header
Sep 4, 2026
Merged

fix: send coder User-Agent on all deployment requests#180
untra merged 1 commit into
mainfrom
user-agent-header

Conversation

@untra

@untra untra commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

.NET's HttpClient omits User-Agent by default, causing AWS WAF to reject requests with 403 on deployments behind an ALB. This blocked sign-in (/api/v2/buildinfo, /api/v2/users/me), and — because Desktop downloads the tunnel binary from the deployment rather than bundling it — Coder Connect could not start either. Closes #176.

What changed

  • CoderSdk/UserAgent.cs (new): formats User-Agent as <token>/<version> (<goos>/<goarch>),
    e.g. coder-desktop/0.8.4 (windows/amd64). Platform names follow Go's GOOS/GOARCH rather than
    .NET's spelling, so a single pattern matches the CLI, the vpn-daemon and every Desktop client.

  • SDK HTTP clients: JsonHttpClient — the single chokepoint both CoderApiClient and
    AgentApiClient route through — now sets DefaultRequestHeaders.UserAgent, selected by a
    CoderComponent enum (Desktop / Core). DefaultRequestHeaders is deliberate: .NET applies it
    only when the request doesn't already carry the header, so caller-supplied headers still win.

  • Vpn.Service: Manager.cs and Downloader.cs identify as CoderComponent.Core, covering the
    buildinfo/users-me calls and the tunnel binary download.

Validation

  • Tests.CoderSdk: 8 → 14 passing (+6 UserAgentTest).
  • Tests.Vpn.Service/DownloaderTest.cs: 26 → 28 (+WithUserAgent, +WithUserAg Both assert the header on the wire via the existing TestHttpServerfixture, including that a caller-suppliedUser-Agent` overrides the default.
  • Tested build in parallels: dotnet build clean, built and ran the arm build with changes, run in windows parallels
Screenshot 2026-09-04 at 7 23 01 AM

@linear-code

linear-code Bot commented Sep 4, 2026

Copy link
Copy Markdown

DEVEX-778

Comment thread Tests.CoderSdk/UserAgentTest.cs
Comment thread Vpn.Service/Downloader.cs
@untra
untra merged commit 527f06a into main Sep 4, 2026
3 checks passed
@untra
untra deleted the user-agent-header branch September 4, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop sends no User-Agent header - all API requests blocked by AWS WAF (NoUserAgent_HEADER) on self-hosted deployments

2 participants