{"record":{"id":"f79b218742a01613","repo":"pranshuparmar/witr","slug":"must-specify-pid-port-file-container-o","errorCode":null,"errorMessage":"must specify --pid, --port, --file, --container, or a process name","messagePattern":"must specify --pid, --port, --file, --container, or a process name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/app/app.go","lineNumber":203,"sourceCode":"\t\treturn runInteractive()\n\t}\n\n\tflags := appFlags{\n\t\tenv:     envFlag,\n\t\texact:   boolFlag(cmd, \"exact\"),\n\t\tshort:   boolFlag(cmd, \"short\"),\n\t\ttree:    boolFlag(cmd, \"tree\"),\n\t\tjson:    boolFlag(cmd, \"json\"),\n\t\twarn:    boolFlag(cmd, \"warnings\"),\n\t\tnoColor: boolFlag(cmd, \"no-color\"),\n\t\tverbose: boolFlag(cmd, \"verbose\"),\n\t}\n\n\t// Collect all targets preserving command-line order\n\ttargets := collectTargetsInOrder(os.Args[1:], args, flagTakesValue(cmd))\n\n\tif len(targets) == 0 {\n\t\treturn withExitCode(ExitInvalidInput, fmt.Errorf(\"must specify --pid, --port, --file, --container, or a process name\"))\n\t}\n\n\toutw := cmd.OutOrStdout()\n\toutp := output.NewPrinter(outw)\n\tmultiMode := len(targets) > 1\n\tcolorEnabled := useColor(flags, outw)\n\n\t// For JSON multi-output, collect all JSON strings and wrap in array\n\tvar jsonResults []string\n\thighestExit := ExitOK\n\n\tfor i, t := range targets {\n\t\tif multiMode && !flags.json {\n\t\t\tprintDivider(outp, t, colorEnabled, i > 0)\n\t\t}\n\n\t\texitCode := processTarget(cmd, outw, outp, t, flags, multiMode, &jsonResults)\n\t\tif exitCode > highestExit {","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/pranshuparmar/witr/blob/dc4fa1da82d3e266fcbd928641b4f30b3077c64f/internal/app/app.go#L185-L221","documentation":"runApp validates that at least one inspection target was supplied on the command line. collectTargetsInOrder found no --pid, --port, --file, --container flag or bare process-name argument, so there is nothing to inspect. The CLI returns ExitInvalidInput for this user error.","triggerScenarios":"Running the binary with no arguments at all, or with only option flags that take no target (e.g. only --json or --exact), or flags whose values were consumed without matching a target keyword.","commonSituations":"Typing the tool name alone to 'see usage'; shell scripts that build the command dynamically and end up with an empty target variable; misremembering flag names (e.g. --pids) so no target is recognized.","solutions":["Add a target: pass --pid <pid>, --port <port>, --file <path>, --container <name>, or a bare process name.","Run with --help to see the exact accepted target flags.","Check your shell script for an empty/misspelled target variable (e.g. \"$PID\" unset).","If scripting, guard against an empty target before invoking the tool."],"exampleFix":"// before\n$ errlookup\n// after\n$ errlookup --pid 1234\n$ errlookup --port 8080\n$ errlookup myserver","handlingStrategy":"validation","validationCode":"args := os.Args[1:]\ntargeted := false\nfor _, a := range args {\n    if strings.HasPrefix(a, \"--pid\") || strings.HasPrefix(a, \"--port\") ||\n        strings.HasPrefix(a, \"--file\") || strings.HasPrefix(a, \"--container\") ||\n        !strings.HasPrefix(a, \"-\") {\n        targeted = true\n        break\n    }\n}\nif !targeted {\n    return errors.New(\"no target given: pass --pid, --port, --file, --container, or a process name\")\n}","typeGuard":null,"tryCatchPattern":"if err := runApp(cmd, args); err != nil {\n    var ec *ExitCodeError\n    if errors.As(err, &ec) && ec.Code == ExitInvalidInput {\n        cmd.Usage()\n    }\n    return err\n}","preventionTips":["Always pass at least one target flag or a process name when scripting.","Check scripts for unset variables that would silently drop the target argument.","Quote process names and validate they are non-empty before invoking."],"tags":["cli","invalid-input","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"dc4fa1da82d3e266fcbd928641b4f30b3077c64f","analyzedAt":"2026-09-01T12:17:08.767Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}