feat: send coder User-Agent on all deployment requests - #264
Merged
Conversation
ethanndickson
self-requested a review
September 4, 2026 15:44
untra
marked this pull request as ready for review
September 4, 2026 16:49
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.
Summary
This is a consistency change, not a bug fix. Injects a default
User-Agentencoding the os and arch (darwin)The problem is that the default carries no Coder identifier (
Coder Desktop/1 CFNetwork/<ver> Darwin/<ver>), so operators can't write one WAF allowlist rule covering every Coder client, and deployment access logs can't tell Desktop traffic apart from any other CFNetwork app. This aligns macOS with the grammar the CLI, the vpn-daemon, and coder/coder-desktop-windows#180 and coder/coder-desktop-linux#7 all use so a single pattern matches all of them.Coder Desktop/1 CFNetwork/<ver> Darwin/<ver>coder-desktop/0.8.4 (darwin/arm64)Coder Desktop/1 CFNetwork/<ver> Darwin/<ver>coder-desktop-core/0.8.4 (darwin/arm64)What changed
CoderSDK/UserAgent.swift(new): formatsUser-Agentas<token>/<version> (<goos>/<goarch>), e.g.coder-desktop/0.8.4 (darwin/arm64).Platform names follow Go's
GOOS/GOARCHrather than Swift's, so#if arch(x86_64)reports
amd64, notx86_64. Version comes fromBundle.main.infoDictionary?["CFBundleShortVersionString"]— the same lookup used inVPNLib/TelemetryEnricher.swift— falling back to0.0.0so the string staysregex-valid.
CoderSDK/HTTP.swift: addsHeaders.userAgentbeside the existingHeaders.sessionToken.doRequest— the single chokepoint bothClientandAgentClientroute through — sets the header, selected by aCoderComponentenum(
app/helper). It is applied only when the caller supplied noUser-Agent:caller headers are attached with
addValue, which comma-joins repeated fields, so anunconditional set would have merged with a user's configured header rather than
yielding to it. Same guarantee as .NET's
DefaultRequestHeaderson the other twoclients.
VPNLib/Download.swift: same treatment on the tunnel binary download.Coder-DesktopHelper/Manager.swift: theClientand the binary download identifyas
CoderComponent.helper, covering the buildinfo call and the tunnel binary. Theparameter defaults to
.app, so no app-side call site changes.Validation
CoderSDKTests: 2 → 9 passing (+7UserAgentTests). Covers both tokens against^coder-desktop(-core)?/[0-9]+\.[0-9]+\.[0-9]+ \(darwin/(amd64|arm64)\)$, that anIntel build reports
amd64and notx86_64, the0.0.0fallback, the header on thewire via the existing
Mockerfixture, and that a caller-suppliedUser-Agentoverrides the default rather than comma-joining with it.
make test: passing, built and started locally (unsigned)