{"record":{"id":"bbe3f020361cad5b","repo":"nats-io/nats-server","slug":"processroutedmsgargs-parse-error-s","errorCode":null,"errorMessage":"processRoutedMsgArgs Parse Error: '%s'","messagePattern":"processRoutedMsgArgs Parse Error: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/route.go","lineNumber":410,"sourceCode":"\t\tcase ' ', '\\t', '\\r', '\\n':\n\t\t\tif start >= 0 {\n\t\t\t\targs = append(args, arg[start:i])\n\t\t\t\tstart = -1\n\t\t\t}\n\t\tdefault:\n\t\t\tif start < 0 {\n\t\t\t\tstart = i\n\t\t\t}\n\t\t}\n\t}\n\tif start >= 0 {\n\t\targs = append(args, arg[start:])\n\t}\n\n\tc.pa.arg = arg\n\tswitch len(args) {\n\tcase 0, 1, 2:\n\t\treturn fmt.Errorf(\"processRoutedMsgArgs Parse Error: '%s'\", args)\n\tcase 3:\n\t\tc.pa.reply = nil\n\t\tc.pa.queues = nil\n\t\tc.pa.szb = args[2]\n\t\tc.pa.size = parseSize(args[2])\n\tcase 4:\n\t\tc.pa.reply = args[2]\n\t\tc.pa.queues = nil\n\t\tc.pa.szb = args[3]\n\t\tc.pa.size = parseSize(args[3])\n\tdefault:\n\t\t// args[2] is our reply indicator. Should be + or | normally.\n\t\tif len(args[2]) != 1 {\n\t\t\treturn fmt.Errorf(\"processRoutedMsgArgs Bad or Missing Reply Indicator: '%s'\", args[2])\n\t\t}\n\t\tswitch args[2][0] {\n\t\tcase '+':\n\t\t\tc.pa.reply = args[3]","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/route.go#L392-L428","documentation":"processRoutedMsgArgs parses the args of an inbound MSG protocol line from another server in the cluster. With fewer than 3 fields (no subject, reply placeholder, and size), the line cannot represent a routed message, so the parse fails. This indicates a malformed or truncated inter-server protocol frame.","triggerScenarios":"Sending/routeing a MSG over a cluster connection with args like '<subject> <size>' only, or an empty/garbled arg string — i.e. less than subject+reply/queue marker+size fields.","commonSituations":"Custom bridge tools speaking raw NATS wire protocol, TCP stream desynchronization after a proxy buffer error, protocol version mismatch between servers, or fuzzing traffic.","solutions":["Fix the sender to emit the full routed MSG arg list: subject, reply (or +/|), and size","Check for stream corruption/desync on the cluster link (proxy, MTU, TLS termination issues)","Upgrade/align NATS Server versions across the cluster","Reproduce with protocol trace logging enabled (trace=true / -DV) to see the raw line"],"exampleFix":"// before (raw wire sender)\nconn.Write([]byte(\"MSG foo 10\\r\\n\"))\n// after\nconn.Write([]byte(fmt.Sprintf(\"MSG foo  10\\r\\n\"))) // subject, empty reply, size","handlingStrategy":"validation","validationCode":"// Validate routed MSG arg count before writing to a route connection\nfields := strings.Split(line, \" \")\nif len(fields) < 3 {\n    return fmt.Errorf(\"routed MSG needs at least subject, reply-indicator, size: %q\", line)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the official NATS client libraries rather than hand-rolled wire protocol","Enable server trace logging in staging to catch malformed frames early","Monitor route connections for repeated parse errors (possible desync)"],"tags":["nats-server","protocol","routing","message-parsing"],"backgroundTag":"malformed-protocol-frame","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}