{"record":{"id":"5081beddcfb3b647","repo":"wavetermdev/waveterm","slug":"procinfo-uid-line-not-found-in-s","errorCode":null,"errorMessage":"procinfo: Uid line not found in %s","messagePattern":"procinfo: Uid line not found in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/util/procinfo/procinfo_linux.go","lineNumber":153,"sourceCode":"\t\t\treturn 0, ErrNotFound\n\t\t}\n\t\treturn 0, fmt.Errorf(\"procinfo: read %s: %w\", path, err)\n\t}\n\tfor _, line := range strings.Split(string(data), \"\\n\") {\n\t\tif !strings.HasPrefix(line, \"Uid:\") {\n\t\t\tcontinue\n\t\t}\n\t\tfields := strings.Fields(line)\n\t\tif len(fields) < 2 {\n\t\t\tbreak\n\t\t}\n\t\tuid, err := strconv.ParseUint(fields[1], 10, 32)\n\t\tif err != nil {\n\t\t\tbreak\n\t\t}\n\t\treturn uint32(uid), nil\n\t}\n\treturn 0, fmt.Errorf(\"procinfo: Uid line not found in %s\", path)\n}\n","sourceCodeStart":135,"sourceCodeEnd":155,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/util/procinfo/procinfo_linux.go#L135-L155","documentation":"readUid parses /proc/<pid>/status looking for the 'Uid:' line; if the file is exhausted without finding it, it returns this error. It means the process's status file did not contain a UID entry, so the process owner could not be determined. Thrown because procinfo cannot fabricate a valid uid and will not silently return 0.","triggerScenarios":"Calling GetProcInfo for a pid whose /proc/<pid>/status lacks a 'Uid:' line — e.g. the process exited between listing and read (file now empty or gone), a kernel thread (kthreadd children have no Uid line), or a file read from a non-standard /proc mount.","commonSituations":"Race conditions with short-lived processes during snapshot enrichment; container environments with masked or minimal /proc (hidepid, seccomp filters); reading status for kernel threads; malformed or mocked /proc in tests.","solutions":["Check the pid still exists (os.Stat /proc/<pid>) before calling GetProcInfo and treat this error as 'process gone'","Skip kernel threads / pids whose status has no Uid line instead of failing the whole operation","Verify /proc is mounted normally and not masked (hidepid=2, containers need /proc/status readable)","Wrap the call to tolerate this error and default the uid (e.g. to 0 or the current user) when non-fatal"],"exampleFix":"// before\ninfo, err := procinfo.GetProcInfo(ctx, snap, pid)\nif err != nil {\n\treturn err\n}\n// after\ninfo, err := procinfo.GetProcInfo(ctx, snap, pid)\nif err != nil {\n\tif strings.Contains(err.Error(), \"Uid line not found\") || errors.Is(err, procinfo.ErrNotFound) {\n\t\treturn nil // process vanished or kernel thread; skip it\n\t}\n\treturn err\n}","handlingStrategy":"try-catch","validationCode":"pidPath := fmt.Sprintf(\"/proc/%d/status\", pid)\nif _, err := os.Stat(pidPath); err != nil {\n\t// process gone; skip call\n}","typeGuard":"func procStatusReadable(pid int32) bool {\n\tf, err := os.Open(fmt.Sprintf(\"/proc/%d/status\", pid))\n\tif err != nil { return false }\n\tdefer f.Close()\n\tdata, err := io.ReadAll(f)\n\treturn err == nil && strings.Contains(string(data), \"Uid:\")\n}","tryCatchPattern":"info, err := procinfo.GetProcInfo(ctx, snap, pid)\nif err != nil {\n\tif strings.Contains(err.Error(), \"Uid line not found\") {\n\t\tcontinue // skip vanished/kernel process\n\t}\n\treturn err\n}","preventionTips":["Re-check /proc/<pid> existence right before enriching a pid","Treat missing Uid/status as a transient race, not a fatal error","Verify /proc is not masked (containers, hidepid) before bulk enumeration","Skip pid 2 (kthreadd) descendants / kernel threads"],"tags":["linux","procfs","process-introspection"],"backgroundTag":"proc-status-parse-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}