{"record":{"id":"6a5ab1c0f4b5dd83","repo":"JuliusBrussee/caveman","slug":"native-runtime-inspect-socket-w","errorCode":null,"errorMessage":"native runtime inspect socket: %w","messagePattern":"native runtime inspect socket: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/nativeruntime/server_unix.go","lineNumber":52,"sourceCode":"\t\treturn errors.New(\"native runtime: store is required\")\n\t}\n\tif err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {\n\t\treturn fmt.Errorf(\"native runtime mkdir: %w\", err)\n\t}\n\tif err := os.Chmod(filepath.Dir(path), 0o700); err != nil {\n\t\treturn fmt.Errorf(\"native runtime chmod dir: %w\", err)\n\t}\n\tif _, err := os.Stat(path); err == nil {\n\t\tconn, dialErr := net.DialTimeout(\"unix\", path, 50*time.Millisecond)\n\t\tif dialErr == nil {\n\t\t\t_ = conn.Close()\n\t\t\treturn errors.New(\"native runtime: socket already active\")\n\t\t}\n\t\tif err := os.Remove(path); err != nil {\n\t\t\treturn fmt.Errorf(\"native runtime remove stale socket: %w\", err)\n\t\t}\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"native runtime inspect socket: %w\", err)\n\t}\n\tlistener, err := net.Listen(\"unix\", path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"native runtime listen: %w\", err)\n\t}\n\tdefer listener.Close()\n\tdefer os.Remove(path)\n\tif err := os.Chmod(path, 0o600); err != nil {\n\t\treturn fmt.Errorf(\"native runtime chmod socket: %w\", err)\n\t}\n\tgo func() {\n\t\t<-ctx.Done()\n\t\t_ = listener.Close()\n\t}()\n\tfor {\n\t\tconn, err := listener.Accept()\n\t\tif err != nil {\n\t\t\tif ctx.Err() != nil {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/nativeruntime/server_unix.go#L34-L70","documentation":"ServeUnix stats the socket path to decide whether it is live, stale, or absent. If Stat fails with an error other than NotExist, it cannot classify the path and returns \"native runtime inspect socket\". This keeps the runtime from blindly listening over an un-inspectable path.","triggerScenarios":"os.Stat(path) returns a non-ENOENT error: permission denied on a parent directory, too many symlinks, I/O error on the filesystem, or path length limits.","commonSituations":"Socket path deep inside directories the user cannot traverse; broken automounts; excessively long socket paths exceeding the unix socket 108-byte limit on stat of parents.","solutions":["Check that every directory component of the socket path is traversable (x permission) by the current user","Shorten the socket path (unix sockets are limited to ~104/108 bytes)","Fix or remount a failing filesystem; remove bad symlinks in the path"],"exampleFix":"// before (path too long / untraversable)\nServeUnix(ctx, \"/very/long/path/.../runtime.sock\", rt)\n// after\nServeUnix(ctx, filepath.Join(os.TempDir(), \"nativeruntime.sock\"), rt)","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(socketPath); err != nil && !os.IsNotExist(err) {\n\treturn fmt.Errorf(\"socket path %s not inspectable: %w\", socketPath, err)\n}\nif len(socketPath) > 100 {\n\treturn errors.New(\"socket path too long\")\n}","typeGuard":null,"tryCatchPattern":"err := nativeruntime.ServeUnix(ctx, path, rt)\nif err != nil {\n\tvar perr *fs.PathError\n\tif errors.As(err, &perr) {\n\t\t// choose a shorter, fully-traversable path\n\t}\n\treturn err\n}","preventionTips":["Use short socket paths under the user's home or /tmp","Verify every path component is traversable by the run user","Avoid deep symlink chains in socket paths"],"tags":["filesystem","socket","stat"],"backgroundTag":"file-not-found","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}