{"record":{"id":"570493a7a51e457e","repo":"pranshuparmar/witr","slug":"no-matching-process-found","errorCode":null,"errorMessage":"no matching process found","messagePattern":"no matching process found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/app/app.go","lineNumber":417,"sourceCode":"\treturn string(data)\n}\n\n// processTarget handles resolving and rendering a single target.\n// Returns the exit code for this target.\nfunc processTarget(cmd *cobra.Command, outw io.Writer, outp output.Printer, t model.Target, flags appFlags, multiMode bool, jsonResults *[]string) int {\n\tcolorEnabled := useColor(flags, outw)\n\n\tif flags.env {\n\t\treturn processEnvTarget(outw, outp, t, flags, multiMode, jsonResults)\n\t}\n\n\tif t.Type == model.TargetContainer {\n\t\treturn processContainerTarget(cmd, outw, outp, t, flags, multiMode, jsonResults)\n\t}\n\n\tpids, err := target.Resolve(t, flags.exact)\n\tif err == nil && len(pids) == 0 {\n\t\terr = fmt.Errorf(\"no matching process found\")\n\t}\n\tif err != nil {\n\t\treturn handleResolveError(cmd, outw, outp, t, err, flags, multiMode, jsonResults)\n\t}\n\n\tif len(pids) > 1 {\n\t\tif multiMode && flags.json {\n\t\t\t*jsonResults = append(*jsonResults, jsonErrorEntry(t, fmt.Sprintf(\"multiple processes matched (%d results)\", len(pids))))\n\t\t} else {\n\t\t\thint := \"witr --pid <pid>\"\n\t\t\tif flags.env {\n\t\t\t\thint = \"witr --pid <pid> --env\"\n\t\t\t}\n\t\t\tprintMultiMatch(outp, pids, colorEnabled, hint)\n\t\t}\n\t\treturn ExitInvalidInput\n\t}\n","sourceCodeStart":399,"sourceCodeEnd":435,"githubUrl":"https://github.com/pranshuparmar/witr/blob/dc4fa1da82d3e266fcbd928641b4f30b3077c64f/internal/app/app.go#L399-L435","documentation":"processTarget resolved the target (process name, pid, port, etc.) via target.Resolve and got no error but an empty pid list — the lookup succeeded syntactically yet matched nothing. The library converts the empty result into this explicit error and routes it through handleResolveError for reporting.","triggerScenarios":"A process-name target that matches no running process; a --pid whose process has exited; a --port with no listening socket; --exact matching where the name differs in case or suffix.","commonSituations":"Typos in process names; service already stopped/crashed; checking a port after the app moved to another port; using the exact flag with a truncated or case-mismatched name.","solutions":["Verify the process exists: run `ps aux | grep <name>` or `lsof -i :<port>` before invoking.","Check the pid is current — the target may have exited; re-resolve it.","Drop --exact or use the full process name if exact matching filtered out your target.","Confirm user permissions: processes owned by other users may be hidden; retry with sudo."],"exampleFix":"// before\ncmd := exec.Command(\"errlookup\", \"myapp\") // crashes: no match after restart\n// after\nif out, err := exec.Command(\"pgrep\", \"-x\", \"myapp\").Output(); err != nil || len(out) == 0 {\n    return fmt.Errorf(\"myapp is not running; start it before inspecting\")\n}\ncmd := exec.Command(\"errlookup\", \"myapp\")","handlingStrategy":"validation","validationCode":"func processExists(name string) bool {\n    out, err := exec.Command(\"pgrep\", \"-f\", name).Output()\n    return err == nil && len(strings.Fields(string(out))) > 0\n}\nif !processExists(\"myapp\") {\n    return errors.New(\"myapp is not running; nothing to inspect\")\n}","typeGuard":null,"tryCatchPattern":"err := runLookup(target)\nif err != nil && strings.Contains(err.Error(), \"no matching process found\") {\n    log.Printf(\"target %q matched no process; skipping\", target.Value)\n    return nil\n}\nif err != nil { return err }","preventionTips":["Confirm the process/port exists with ps/lsof before lookup.","Re-resolve pids at run time instead of caching them across restarts.","Avoid --exact unless you pass the full, case-correct process name.","Run with sufficient privileges (same user or sudo) to see all processes."],"tags":["process-resolution","cli","not-found"],"backgroundTag":"process-not-found","analyzedSha":"dc4fa1da82d3e266fcbd928641b4f30b3077c64f","analyzedAt":"2026-09-01T12:17:08.767Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}