nats-io/nats-server · error

Received invalid peer name for remove proposal: %q

Error message

Received invalid peer name for remove proposal: %q

What it means

A forwarded remove-peer proposal arrived whose payload length != idLen, so it cannot be a valid peer name. The malformed proposal is rejected (warned) rather than being applied, protecting membership from garbage input — likely a version mismatch or a corrupted/foreign message on the subject.

Source

Thrown at server/raft.go:3238

	ar.index = le.Uint64(msg[8:])

	peer, ok := peers.Load(string(msg[16 : 16+idLen]))
	if !ok {
		// We missed so store inline here.
		peer = string(msg[16 : 16+idLen])
		peers.Store(peer, peer)
	}
	ar.peer = peer.(string)
	ar.success = msg[24] == 1
	return ar
}

// Called when a remove peer proposal has been forwarded
func (n *raft) handleForwardedRemovePeerProposal(sub *subscription, c *client, _ *Account, _, reply string, msg []byte) {
	n.debug("Received forwarded remove peer proposal: %q", msg)

	if len(msg) != idLen {
		n.warn("Received invalid peer name for remove proposal: %q", msg)
		return
	}

	n.RLock()
	// Check state under lock, we might not be leader anymore.
	if n.State() != Leader || !n.leaderState.Load() {
		n.debug("Ignoring forwarded peer removal proposal, not leader")
		n.RUnlock()
		return
	}
	// Error if we had a previous write error.
	if werr := n.werr; werr != nil {
		n.RUnlock()
		return
	}
	if n.membChange != nil {
		n.debug("Ignoring forwarded peer removal proposal, membership changing")
		n.RUnlock()

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. Verify all cluster nodes run compatible versions
  2. Check that nothing else publishes to the internal RAFT proposals subject
  3. Ignore one-offs; repeated occurrences indicate a real publisher bug
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server/raft.go:3238 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/ec2e7d0438513bb0. Report an issue: GitHub.