Open
Conversation
This was referenced May 7, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5215 +/- ##
==========================================
- Coverage 67.79% 67.77% -0.03%
==========================================
Files 608 610 +2
Lines 62234 62288 +54
==========================================
+ Hits 42191 42214 +23
- Misses 16869 16899 +30
- Partials 3174 3175 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replace prefix-and-trim string handling with net/url.Parse on both
the producer (socketURL) and the consumer (HTTPClientForURL,
ParseNamedPipeURL, ParseUnixSocketPath) sides so pipe and socket
addresses round-trip through one library and one set of rules.
socketURL now emits unix:///<path> via (&url.URL{}).String(),
which fixes a real bug on Windows AF_UNIX paths: the previous
concatenation form produced unix://C:\path\thv.sock, which
url.Parse rejects with "invalid port :\\path\\thv.sock". The
round-trip is exercised by new tests on both platforms.
HTTPClientForURL now dispatches on url.Parse + switch u.Scheme,
which gives case-insensitive scheme matching (NPIPE://x routes the
same as npipe://x) for free and matches what the http arm already
does via ValidateLoopbackURL.
ParseNamedPipeURL gains explicit checks that net/url alone cannot
do: a 247-character cap (CreateNamedPipeW's lpName limit minus the
\\.\pipe\ prefix), the legacy reserved Windows device names
(CON, NUL, COM1-9, LPT1-9, ...), and a positive charset of
[A-Za-z0-9._-]+. Names are lowercased via strings.ToLower because
the pipe namespace is case-insensitive at the kernel layer; the
old strings.Contains(name, "..") guard is removed because it
rejected legitimate names like my..api.
ParseUnixSocketPath rejects URLs with non-empty authority, query,
fragment, or userinfo; it also strips the synthetic leading slash
that url.URL inserts in front of Windows drive letters so
unix:///C:%5Cpath%5Cthv.sock round-trips back to C:\path\thv.sock.
Co-authored-by: Cursor <cursoragent@cursor.com>
9a83a9d to
24b1dfe
Compare
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
Follow-up to #5201 (review thread). Stacked on
socker-windows; will rebase ontomainonce #5201 merges. Sibling to #5214.Replaces prefix-and-trim string handling with
net/url.Parseon both producer (socketURL) and consumer (HTTPClientForURL,ParseNamedPipeURL,ParseUnixSocketPath) sides so pipe and socket addresses round-trip through one library and one set of rules.The change includes one real bug fix:
socketURLpreviously emittedunix://C:\path\thv.sockfor Windows AF_UNIX paths, whichurl.Parserejects withinvalid port ":\\path\\thv.sock". The dispatcher only worked because it usedstrings.TrimPrefix. New behavior emitsunix:///C:%5Cpath%5Cthv.sock, which round-trips cleanly. Round-trip is now exercised byTestSocketURL_RoundTrip_UnixandTestSocketURL_RoundTrip_NamedPipe.Other improvements that fall out of the migration:
NPIPE://xroutes the same arm asnpipe://xbecauseurl.Parselowercases the scheme during parsing. Pinned byTestHTTPClientForURL_SchemeDispatchCaseInsensitive.npipe://Thv-APIresolves to\\.\pipe\thv-apiviastrings.ToLower(u.Hostname()); matches the kernel's case-insensitive pipe namespace.CreateNamedPipeWlpNamelimit after the\\.\pipe\prefix).CON,NUL,PRN,AUX,COM1-9,LPT1-9).[A-Za-z0-9._-]+for pipe names — replaces the over-eagerstrings.Contains(name, "..")guard which rejected legitimate names likemy..api.ParseNamedPipeURLrejects pipe URLs with non-empty path / query / fragment / userinfo / port;ParseUnixSocketPathrejects unix URLs with non-empty authority.Addresses inline review comments 3201085366 (
ParseNamedPipeURLmigration), 3201085375 (dispatcher migration), and 3201085383 (socketURL/ParseUnixSocketPathmigration + Windows AF_UNIX bug).Type of change
Test plan
go test ./pkg/api/... ./pkg/server/discovery/...) — green on macOS; new round-trip tests, scheme-case test, reserved-name tests, length-cap test, and shape-rejection cases all pass.task lint-fix— 0 issues.GOOS=windows go vetandGOOS=windows go test -c -o /dev/nullfor both packages — both clean.Does this introduce a user-facing change?
Yes (Windows-only). On Windows,
socketURLfor AF_UNIX paths now emits a percent-encoded URL form. The discovery file is local per-user and overwritten on everythv servestartup, so there is no on-disk migration concern. POSIX paths like/tmp/thv.sockproduce identical output before and after.Made with Cursor