Skip to content

Windows: AF_UNIX unix:// URLs fail to parse and round-trip #6291

Description

@stantheman0128

Summary

On Windows, in-tree AF_UNIX discovery tests fail at HEAD (3c4dec3). Named-pipe (npipe://) tests on the same machine pass. No container runtime is involved.

I intend to implement a fix. Per CONTRIBUTING I will wait for assignment before opening a PR.

Environment

  • Windows 11, go version go1.26.5 windows/amd64
  • HEAD: 3c4dec3
go test ./pkg/server/discovery/ -count=1 -run "TestParseUnixSocketPath_Valid$|TestHTTPClientForURL_SchemeDispatchCaseInsensitive|TestCheckHealth_UnixSocket_Success$"

Failures

POSIX unix:/// paths rejected as relative

ParseUnixSocketPath("unix:///var/run/thv.sock") returns:

unix socket path must be absolute: \var\run\thv.sock

filepath.Clean on Windows turns /var/run/thv.sock into \var\run\thv.sock, and filepath.IsAbs is false because there is no volume. Same for HTTPClientForURL("UNIX:///tmp/thv.sock") -> \tmp\thv.sock.

Concatenating unix:// + a drive path is not a valid URL

TestCheckHealth_UnixSocket_Success builds "unix://"+socketPath. On Windows that is unix://C:\Users\...\test.sock. url.Parse rejects it:

invalid server URL: parse "unix://C:\\Users\\stans\\AppData\\Local\\Temp\\thv-3078206842\\test.sock": invalid port ":\\Users\\stans\\AppData\\Local\\Temp\\thv-3078206842\\test.sock" after host

pkg/api/socket_windows.go already documents this and emits unix:///C:%5Cpath%5Cthv.sock. The discovery tests still concatenate.

ListenURL four slashes

Windows socketURL does Path: "/" + address. When address is already /tmp/test.sock, ListenURL returns unix:////tmp/test.sock (four slashes) instead of unix:///tmp/test.sock. The Unix build of socketURL uses Path: address and does not add that extra slash.

What is not broken

  • Named-pipe setup, DACL, and first-instance-wins tests are green.
  • TestSocketURL_RoundTrip_AFUnix for C:\path\thv.sock via socketURL() already percent-encodes correctly.

Direction (after assignment)

Keep the three-slash encoded form that socket_windows.go already documents. Make ParseUnixSocketPath accept POSIX unix:///var/run/... on Windows (or skip those cases on Windows). Stop tests from concatenating unix:// + a drive path; use socketURL / url.URL. Do not prepend / when address already starts with /.

Happy to take this once assigned.

Filed with AI assistance (Cursor/Grok). Reproduced on this machine.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions