{"record":{"id":"7bfa106b58fbdeef","repo":"nats-io/nats-server","slug":"processsub-parse-error-q","errorCode":null,"errorMessage":"processSub Parse Error: %q","messagePattern":"processSub Parse Error: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/client.go","lineNumber":3049,"sourceCode":"\targ := make([]byte, len(argo))\n\tcopy(arg, argo)\n\targs := splitArg(arg)\n\tvar (\n\t\tsubject []byte\n\t\tqueue   []byte\n\t\tsid     []byte\n\t)\n\tswitch len(args) {\n\tcase 2:\n\t\tsubject = args[0]\n\t\tqueue = nil\n\t\tsid = args[1]\n\tcase 3:\n\t\tsubject = args[0]\n\t\tqueue = args[1]\n\t\tsid = args[2]\n\tdefault:\n\t\treturn fmt.Errorf(\"processSub Parse Error: %q\", arg)\n\t}\n\t// If there was an error, it has been sent to the client. We don't return an\n\t// error here to not close the connection as a parsing error.\n\tc.processSub(subject, queue, sid, nil, noForward)\n\treturn nil\n}\n\nfunc (c *client) processSub(subject, queue, bsid []byte, cb msgHandler, noForward bool) (*subscription, error) {\n\treturn c.processSubEx(subject, queue, bsid, cb, noForward, false, false)\n}\n\nfunc (c *client) processSubEx(subject, queue, bsid []byte, cb msgHandler, noForward, si, rsi bool) (*subscription, error) {\n\t// Create the subscription\n\tsub := &subscription{client: c, subject: subject, queue: queue, sid: bsid, icb: cb, si: si, rsi: rsi}\n\n\tc.mu.Lock()\n\n\t// Indicate activity.","sourceCodeStart":3031,"sourceCodeEnd":3067,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/client.go#L3031-L3067","documentation":"The SUB protocol operation had an invalid argument count. processSub accepts 2 args (subject, sid) or 3 args (subject, queue, sid); anything else returns this parse error. Note the comment in the source: the parse error is returned but for actual subscription errors the connection is not closed; a parse error here does terminate the client connection.","triggerScenarios":"Client sends `SUB` with 0, 1, or more than 3 tokens, e.g. `SUB subject` (missing sid) or `SUB a b c d`, so the switch falls to default.","commonSituations":"Hand-written SUB frames in scripts or tests, queue-group clients emitting an extra token, proxy mangling whitespace, buggy custom client.","solutions":["Send SUB with exactly `SUB <subject> <sid>` or `SUB <subject> <queue> <sid>` followed by CRLF","Fix or upgrade the client library building SUB frames","Check logs/traffic capture for the exact malformed SUB line"],"exampleFix":"// before\nSUB subject\n// after\nSUB subject 1","handlingStrategy":"validation","validationCode":"if queue == \"\" {\n    frame = fmt.Sprintf(\"SUB %s %s\\r\\n\", subject, sid)\n} else {\n    frame = fmt.Sprintf(\"SUB %s %s %s\\r\\n\", subject, queue, sid)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply a non-empty subject and sid","Emit the queue group token only when a queue is actually used","Validate subjects contain no whitespace"],"tags":["protocol","parsing","subscription"],"backgroundTag":"nats-protocol-parse-error","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}