{"record":{"id":"df2db907ab2845fe","repo":"nats-io/nats-server","slug":"processgatewaysubjectsub-parse-error-s","errorCode":null,"errorMessage":"processGatewaySubjectSub Parse Error: '%s'","messagePattern":"processGatewaySubjectSub Parse Error: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/gateway.go","lineNumber":2044,"sourceCode":"// from remote gateway.\n// <Invoked from outbound connection's readLoop>\nfunc (c *client) processGatewayRSub(arg []byte) error {\n\t// Indicate activity.\n\tc.in.subs++\n\n\tvar (\n\t\tqueue []byte\n\t\tqw    int32\n\t)\n\n\targs := splitArg(arg)\n\tswitch len(args) {\n\tcase 2:\n\tcase 4:\n\t\tqueue = args[2]\n\t\tqw = int32(parseSize(args[3]))\n\tdefault:\n\t\treturn fmt.Errorf(\"processGatewaySubjectSub Parse Error: '%s'\", arg)\n\t}\n\taccName := args[0]\n\tsubject := args[1]\n\n\tvar (\n\t\te          *outsie\n\t\tuseSl      bool\n\t\tnewe       bool\n\t\tcallUpdate bool\n\t\tsrv        *Server\n\t\tsub        *subscription\n\t)\n\n\t// Possibly execute this on exit after all locks have been released.\n\t// If callUpdate is true, srv and sub will be not nil.\n\tdefer func() {\n\t\tif callUpdate {\n\t\t\tsrv.updateInterestForAccountOnGateway(string(accName), sub, 1)","sourceCodeStart":2026,"sourceCodeEnd":2062,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/gateway.go#L2026-L2062","documentation":"Raised inside processGatewaySubjectSub when the raw gateway SUB arguments do not have exactly 2 fields (account, subject) or 4 fields (account, subject, queue, weight). It indicates a malformed gateway subscription message arriving from a remote gateway.","triggerScenarios":"Remote gateway sends 'LS+/RS+' subscription protocol with wrong field count: missing account or subject, or a queue+weight pair where only one is present; parseSize on args[3] may also fail on non-numeric queue weight.","commonSituations":"Version skew between clustered NATS servers changing the gateway SUB format; broken middleware/proxy truncating frames; a rogue process speaking garbage on the gateway port.","solutions":["Align NATS server versions across all gateway-connected clusters","Enable gateway trace logging (debug/trace flags) to inspect the malformed frame and its origin","Inspect network path (load balancers, proxies) for frame corruption or truncation","Restart the offending gateway connection after fixing the peer"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Same family as 490: validate inter-server compatibility before forming gateway connections\n// and run with gateway tracing in staging to detect malformed SUB frames.\n// nats-server flag example: --cluster ... --gateway ... --trace_verbose (staging only)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin and test a single NATS server version across all clusters","Avoid custom proxies on gateway ports; if unavoidable, verify they preserve framing","Roll gateway config changes with canary clusters first","Alert on 'Parse Error' log lines from gateway handlers"],"tags":["gateway","protocol","parse-error","cluster"],"backgroundTag":"gateway-protocol-parse-error","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}