{"record":{"id":"5e160988278376a9","repo":"wavetermdev/waveterm","slug":"socket-path-must-be-absolute-s","errorCode":null,"errorMessage":"socket path must be absolute: %s","messagePattern":"socket path must be absolute: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wshutil/wshutil.go","lineNumber":195,"sourceCode":"\treturn rtn, writeErrCh, nil\n}\n\nfunc tryTcpSocket(sockName string) (net.Conn, error) {\n\taddr, err := net.ResolveTCPAddr(\"tcp\", sockName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn net.DialTCP(\"tcp\", nil, addr)\n}\n\nfunc SetupDomainSocketRpcClient(sockName string, serverImpl ServerImpl, debugName string) (*WshRpc, error) {\n\tsockName = wavebase.ExpandHomeDirSafe(sockName)\n\tresolvedPath, err := filepath.EvalSymlinks(sockName)\n\tif err == nil {\n\t\tsockName = resolvedPath\n\t}\n\tif !filepath.IsAbs(sockName) {\n\t\treturn nil, fmt.Errorf(\"socket path must be absolute: %s\", sockName)\n\t}\n\tconn, tcpErr := tryTcpSocket(sockName)\n\tvar unixErr error\n\tif tcpErr != nil {\n\t\tconn, unixErr = net.Dial(\"unix\", sockName)\n\t}\n\tif tcpErr != nil && unixErr != nil {\n\t\treturn nil, fmt.Errorf(\"failed to connect to tcp or unix domain socket: tcp err:%w: unix socket err: %w\", tcpErr, unixErr)\n\t}\n\trtn, errCh, err := SetupConnRpcClient(conn, serverImpl, debugName)\n\tgo func() {\n\t\tdefer func() {\n\t\t\tpanichandler.PanicHandler(\"SetupDomainSocketRpcClient:closeConn\", recover())\n\t\t}()\n\t\tdefer conn.Close()\n\t\terr := <-errCh\n\t\tif err != nil && err != io.EOF {\n\t\t\tlog.Printf(\"error in domain socket connection: %v\\n\", err)","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wshutil/wshutil.go#L177-L213","documentation":"SetupDomainSocketRpcClient connects to a Wave RPC server over a domain socket. Before dialing, it expands home-dir prefixes and resolves symlinks, then requires the final path to be absolute. A relative path cannot be used reliably for socket dialing, so it is rejected with this error.","triggerScenarios":"Calling SetupDomainSocketRpcClient (or setupRpcClient/Connect which route through it) with a sockName that is relative after ExpandHomeDirSafe and symlink resolution — e.g. \"run/waveterm.sock\" or a bare filename without a leading \"/\" or \"~\".","commonSituations":"Config file containing a relative socket path; assuming cwd-relative resolution; env-specific socket paths configured without an absolute prefix.","solutions":["Pass an absolute socket path (e.g. \"/home/user/.waveterm/run/app.sock\") or use \"~/...\" so ExpandHomeDirSafe resolves it.","Verify the configured path with filepath.IsAbs before calling.","Check the config/source of sockName for a missing leading slash or missing ~ prefix.","If the socket path comes from an env var, ensure it is set to a fully qualified path."],"exampleFix":"// before\nconn, _, _ := wshutil.SetupDomainSocketRpcClient(ctx, impl, \"run/app.sock\", \"debug\")\n// after\nsock := \"/home/user/.waveterm/run/app.sock\" // or \"~/\\.waveterm/run/app.sock\"\nconn, _, _ := wshutil.SetupDomainSocketRpcClient(ctx, impl, sock, \"debug\")","handlingStrategy":"validation","validationCode":"sock := wavebase.ExpandHomeDirSafe(sockName)\nif !filepath.IsAbs(sock) {\n    return fmt.Errorf(\"socket path must be absolute, got %q\", sockName)\n}","typeGuard":null,"tryCatchPattern":"if _, _, err := SetupDomainSocketRpcClient(ctx, impl, sockName, dbg); err != nil {\n    if strings.Contains(err.Error(), \"socket path must be absolute\") {\n        sockName = filepath.Join(\"/\", sockName) // or fix config\n        return retryWithAbsolutePath(sockName)\n    }\n    return err\n}","preventionTips":["Store absolute paths (or ~/...) in config for socket locations","Run filepath.IsAbs checks on any dynamically built socket path","Avoid depending on the process working directory for socket resolution"],"tags":["go","config","unix-socket","validation"],"backgroundTag":"invalid-socket-path","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}