{"record":{"id":"e8ef6659d85e7531","repo":"gastownhall/beads","slug":"empty-executable-basename-for-pid-d","errorCode":null,"errorMessage":"empty executable basename for pid %d","messagePattern":"empty executable basename for pid (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/dbproxy/proxy/process_executable_darwin.go","lineNumber":27,"sourceCode":"\t\"path/filepath\"\n\t\"strconv\"\n\t\"strings\"\n\t\"syscall\"\n\n\t\"golang.org/x/sys/unix\"\n)\n\nfunc processExecutableBasename(pid int) (basename string, gone bool, err error) {\n\toutput, commandErr := exec.Command(\"ps\", \"-p\", strconv.Itoa(pid), \"-o\", \"comm=\").Output()\n\tif commandErr != nil {\n\t\tif killErr := syscall.Kill(pid, 0); errors.Is(killErr, unix.ESRCH) {\n\t\t\treturn \"\", true, nil\n\t\t}\n\t\treturn \"\", false, commandErr\n\t}\n\tbase := filepath.Base(strings.TrimSpace(string(output)))\n\tif base == \".\" || base == string(filepath.Separator) || base == \"\" {\n\t\treturn \"\", false, fmt.Errorf(\"empty executable basename for pid %d\", pid)\n\t}\n\treturn base, false, nil\n}\n","sourceCodeStart":9,"sourceCodeEnd":31,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/dbproxy/proxy/process_executable_darwin.go#L9-L31","documentation":"On macOS, processExecutableBasename resolves a pid's executable via a command (ps-style lookup) and takes its basename. If the trimmed output is '.', the path separator, or empty, the resolved name is unusable, so the library returns this error rather than comparing against a garbage executable name.","triggerScenarios":"Calling processExecutableBasename on darwin for a pid whose executable path resolves to an empty/invalid basename — typically a just-exited or reaped process whose command output is empty.","commonSituations":"Pid exited between lookup and verification; zombie process with no command; pid recycled to a kernel process with odd metadata.","solutions":["Retry the lookup; the pid may have been in transient state","Verify the pid is alive before verification (e.g. signal 0 check)","Fall back to a different executable-resolution method or skip verification for that pid"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if !pidAlive(pid) { return fmt.Errorf(\"pid %d not running\", pid) }","typeGuard":"func validBasename(b string) bool { return b != \"\" && b != \".\" && b != \"/\" }","tryCatchPattern":"base, exited, err := processExecutableBasename(pid)\nif err != nil { /* treat as unverified or retry */ }","preventionTips":["Confirm the pid is alive before verification","Retry transient lookup failures with backoff","Handle exited==true before treating the error as fatal"],"tags":["process","darwin","verification"],"backgroundTag":"empty-executable-basename","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}