nats-io/nats-server · error

processRoutedHeaderMsgArgs Bad or Missing Size: '%s'

Error message

processRoutedHeaderMsgArgs Bad or Missing Size: '%s'

What it means

The total-size token (last argument) of the routed header message failed parseSize, returning a negative value for what must be a non-negative byte count. The parsed args are echoed; indicates a malformed size field or token misalignment in the HMSG argument line received over the route.

Source

Thrown at server/route.go:362

		c.pa.hdb = args[len(args)-2]
		c.pa.hdr = parseSize(c.pa.hdb)

		// Grab size.
		c.pa.szb = args[len(args)-1]
		c.pa.size = parseSize(c.pa.szb)

		// Grab queue names.
		if c.pa.reply != nil {
			c.pa.queues = args[4 : len(args)-2]
		} else {
			c.pa.queues = args[3 : len(args)-2]
		}
	}
	if c.pa.hdr < 0 {
		return fmt.Errorf("processRoutedHeaderMsgArgs Bad or Missing Header Size: '%s'", arg)
	}
	if c.pa.size < 0 {
		return fmt.Errorf("processRoutedHeaderMsgArgs Bad or Missing Size: '%s'", args)
	}
	if c.pa.hdr > c.pa.size {
		return fmt.Errorf("processRoutedHeaderMsgArgs Header Size larger then TotalSize: '%s'", arg)
	}

	// Common ones processed after check for arg length
	c.pa.account = args[0]
	c.pa.subject = args[1]
	if len(an) > 0 {
		c.pa.pacache = c.pa.subject
	} else {
		c.pa.pacache = arg[:len(args[0])+len(args[1])+1]
	}
	return nil
}

// Process an inbound RMSG or LMSG specification from the remote route.
func (c *client) processRoutedMsgArgs(arg []byte) error {

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Confirm the total size token is a valid non-negative integer
  2. Check for route protocol version mismatch
  3. Inspect for payload corruption introduced by network intermediaries
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/route.go:362 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/ebfccd407c6117f8. Report an issue: GitHub.