{"record":{"id":"9c078e966106d995","repo":"docker/compose","slug":"socket-address-is-too-long-s","errorCode":null,"errorMessage":"socket address is too long: %s","messagePattern":"socket address is too long: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/memnet/conn_unix.go","lineNumber":36,"sourceCode":"\npackage memnet\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net\"\n\t\"syscall\"\n)\n\nconst maxUnixSocketPathSize = len(syscall.RawSockaddrUnix{}.Path)\n\nfunc dialNamedPipe(_ context.Context, _ string) (net.Conn, error) {\n\treturn nil, fmt.Errorf(\"named pipes are only available on Windows\")\n}\n\nfunc validateSocketPath(addr string) error {\n\tif len(addr) > maxUnixSocketPathSize {\n\t\treturn fmt.Errorf(\"socket address is too long: %s\", addr)\n\t}\n\treturn nil\n}\n","sourceCodeStart":18,"sourceCodeEnd":40,"githubUrl":"https://github.com/docker/compose/blob/ddc4b044b62e9f715212ea4143fa830fac76382f/internal/memnet/conn_unix.go#L18-L40","documentation":"Before dialing a Unix socket, memnet validates that the path fits in sockaddr_un.Path (108 bytes on Linux, ~104 on macOS) — the kernel hard limit for Unix socket addresses. A longer path cannot be represented in the sockaddr, so dial would fail with a cryptic EINVAL/ENAMETOOLONG; validateSocketPath fails fast with the offending path instead.","triggerScenarios":"Calling memnet.Dial/DialEndpoint with a unix:// address whose path exceeds the platform sockaddr_un.Path size — e.g. sockets created deep under long project directories (common with testcontainers, tmpdirs nested in $PWD, or XDG_RUNTIME_DIR with long usernames).","commonSituations":"CI checkout paths like /home/runner/work/very-long-repo-and-branch-name/... plus nested temp dirs pushing the socket path past ~104 chars; Docker contexts whose socket lives under a deeply nested runtime dir; tests generating sockets under t.TempDir() inside long absolute paths.","solutions":["Shorten the socket path: create sockets in /tmp, $XDG_RUNTIME_DIR root, or another shallow directory.","Compute and assert path length before creating/dialing: len(path) < 108 on Linux (104 on macOS).","Use abstract Unix sockets only if the API supports them (this path-based API does not).","Move long-running CI workloads to a shorter checkout directory (e.g. /w or /srv) if the path comes from the workspace."],"exampleFix":"# before: socket path too long\nunix:///home/user/work/very/long/nested/path/runtime/dir/docker-api-proxy.sock\n\n# after\nunix:///tmp/dd-proxy.sock","handlingStrategy":"validation","validationCode":"const maxUnixPath = 104 // conservative across linux(108)/macOS(104)\nfunc socketPathFits(p string) bool { return len(p) <= maxUnixPath }\nif !socketPathFits(path) { /* pick a shorter dir */ }","typeGuard":null,"tryCatchPattern":"conn, err := memnet.Dial(ctx, \"unix\", addr)\nif err != nil {\n    if len(addr) > 104 {\n        err = fmt.Errorf(\"socket path too long (%d bytes); move socket to a shallow dir: %w\", len(addr), err)\n    }\n    return nil, err\n}","preventionTips":["Create sockets under /tmp, /run, or $XDG_RUNTIME_DIR, not deep project trees.","Assert path length before bind/dial in tests.","Shorten long CI checkout paths."],"tags":["unix-socket","path-length","validation","platform","go"],"backgroundTag":null,"analyzedSha":"ddc4b044b62e9f715212ea4143fa830fac76382f","analyzedAt":"2026-08-15T13:31:42.319Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}