hyperledger/fabric · error

Failed unmarshalling GossipMessage from envelope: %v

Error message

Failed unmarshalling GossipMessage from envelope: %v

What it means

EnvelopeToGossipMessage wraps any proto.Unmarshal failure of the envelope's Payload into this error. It indicates the payload bytes are not a valid serialized GossipMessage (truncated, corrupt, or wrong message type).

Source

Thrown at gossip/protoext/signing.go:67

	}
	sMsg := &SignedGossipMessage{
		GossipMessage: m,
	}
	_, err := sMsg.Sign(signer)
	return sMsg, err
}

// EnvelopeToGossipMessage un-marshals a given envelope and creates a
// SignedGossipMessage out of it.
// Returns an error if un-marshaling fails.
func EnvelopeToGossipMessage(e *gossip.Envelope) (*SignedGossipMessage, error) {
	if e == nil {
		return nil, errors.New("nil envelope")
	}
	msg := &gossip.GossipMessage{}
	err := proto.Unmarshal(e.Payload, msg)
	if err != nil {
		return nil, fmt.Errorf("Failed unmarshalling GossipMessage from envelope: %v", err)
	}
	return &SignedGossipMessage{
		GossipMessage: msg,
		Envelope:      e,
	}, nil
}

// InternalEndpoint returns the internal endpoint in the secret envelope, or an
// empty string if a failure occurs.
func InternalEndpoint(s *gossip.SecretEnvelope) string {
	if s == nil {
		return ""
	}
	secret := &gossip.Secret{}
	if err := proto.Unmarshal(s.Payload, secret); err != nil {
		return ""
	}
	return secret.GetInternalEndpoint()

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Verify the envelope Payload was produced by proto.Marshal of a gossip.GossipMessage
  2. Align fabric/proto versions between sender and receiver
  3. Log the raw payload (hex) and inspect it to identify truncation or wrong message type

Example fix

// before
payload := []byte("some non-proto data")
envelope.Payload = payload
// after
b, _ := proto.Marshal(gossipMsg)
envelope.Payload = b
Defensive patterns

Strategy: try-catch

Validate before calling

if len(env.Payload) == 0 {
    return errors.New("envelope has empty payload")
}

Type guard

func hasPayload(e *gossip.Envelope) bool { return e != nil && len(e.Payload) > 0 }

Try / catch

msg, err := protoext.EnvelopeToGossipMessage(env)
if err != nil {
    return nil, fmt.Errorf("dropping undecodable envelope: %w", err)
}

Prevention

When it happens

Trigger: Calling EnvelopeToGossipMessage with an envelope whose Payload is empty or was produced by a different proto message type/version, or corrupted during transport/storage.

Common situations: Peers running incompatible fabric versions with changed gossip proto definitions; envelopes stored by an older version and read by a newer one; network corruption or hand-crafted test payloads.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/d27c470a72c28b9a. Report an issue: GitHub.