{"record":{"id":"ee9343cd6bd59904","repo":"nats-io/nats-server","slug":"invalid-signal-parameters-v","errorCode":null,"errorMessage":"invalid signal parameters: %v","messagePattern":"invalid signal parameters: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/opts.go","lineNumber":6570,"sourceCode":"\t} else {\n\t\t// Since we override from flag and there is no user/pwd, make\n\t\t// sure we clear what we may have gotten from config file.\n\t\topts.Cluster.Username = _EMPTY_\n\t\topts.Cluster.Password = _EMPTY_\n\t}\n\n\treturn nil\n}\n\nfunc processSignal(signal string) error {\n\tvar (\n\t\tpid           string\n\t\tcommandAndPid = strings.Split(signal, \"=\")\n\t)\n\tif l := len(commandAndPid); l == 2 {\n\t\tpid = maybeReadPidFile(commandAndPid[1])\n\t} else if l > 2 {\n\t\treturn fmt.Errorf(\"invalid signal parameters: %v\", commandAndPid[2:])\n\t}\n\tif err := ProcessSignal(Command(commandAndPid[0]), pid); err != nil {\n\t\treturn err\n\t}\n\tos.Exit(0)\n\treturn nil\n}\n\n// maybeReadPidFile returns a PID or Windows service name obtained via the following method:\n// 1. Try to open a file with path \"pidStr\" (absolute or relative).\n// 2. If such a file exists and can be read, return its contents.\n// 3. Otherwise, return the original \"pidStr\" string.\nfunc maybeReadPidFile(pidStr string) string {\n\tif b, err := os.ReadFile(pidStr); err == nil {\n\t\treturn string(b)\n\t}\n\treturn pidStr\n}","sourceCodeStart":6552,"sourceCodeEnd":6588,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/opts.go#L6552-L6588","documentation":"The NATS server signal (nats-server -s/-signal) parsing accepts signal=pid or signal=pidfile with at most one '=' separator. If the argument splits into more than two parts (multiple '=' signs), the extra parameters are invalid and this error lists them.","triggerScenarios":"Passing a -s/--signal argument like `stop=123=456` or a value containing multiple '=' characters so strings.Split yields >2 elements.","commonSituations":"Shell quoting mistakes producing duplicated arguments glued with '=', copy-paste of 'reload=pid' with an extra suffix, or scripting that appends an unintended '=value'.","solutions":["Use the form `nats-server -s stop=<pid>` (exactly one '=').","Remove any extra '=...' segments from the signal argument.","Quote the argument in the shell if it contains special characters.","To signal by pid file, use stop=/path/to/pidfile with a single '='."],"exampleFix":"// before\nnats-server -s reload=1234=extra\n// after\nnats-server -s reload=1234","handlingStrategy":"validation","validationCode":"// Validate the -s argument format before invoking\nsig=\"$1\"\nparts=$(echo \"$sig\" | awk -F= '{print NF-1}')\nif [ \"$parts\" -gt 1 ]; then echo \"signal arg must be signal=<pid|pidfile>\"; exit 1; fi","typeGuard":"func isValidSignalArg(s string) bool {\n    parts := strings.Split(s, \"=\")\n    return len(parts) == 1 || len(parts) == 2\n}","tryCatchPattern":"if err := ProcessSignalArg(signalArg); err != nil {\n    return fmt.Errorf(\"bad -s argument %q: use stop|quit|reload=<pid|pidfile>\", signalArg)\n}","preventionTips":["Use exactly one '=' in signal arguments: stop=1234.","Quote the argument in shell scripts.","Signal by pid file path when the PID is not known directly."],"tags":["cli","signals","argument-parsing"],"backgroundTag":"invalid-cli-argument","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}