hyperledger/fabric · error

failed unmarshalling peer's identity

Error message

failed unmarshalling peer's identity

What it means

The discovery client received a valid StateInfo/Alive pair from a peer, but the peer.Identity bytes inside the gossip AliveMessage could not be unmarshalled into an msp.SerializedIdentity proto. This identity is needed to extract the peer's MSP ID for endorsement descriptor selection, so the Peer cannot be constructed and the query fails.

Source

Thrown at discovery/client/client.go:551

		return nil, errors.Errorf("received empty envelope(s) for endorsers for chaincode %s, channel %s", chaincode, channel)
	}
	aliveMsg, err := gprotoext.EnvelopeToGossipMessage(peer.MembershipInfo)
	if err != nil {
		return nil, errors.Wrap(err, "failed unmarshalling gossip envelope to alive message")
	}
	stateInfMsg, err := gprotoext.EnvelopeToGossipMessage(peer.StateInfo)
	if err != nil {
		return nil, errors.Wrap(err, "failed unmarshalling gossip envelope to state info message")
	}
	if err := validateAliveMessage(aliveMsg); err != nil {
		return nil, errors.Wrap(err, "failed validating alive message")
	}
	if err := validateStateInfoMessage(stateInfMsg); err != nil {
		return nil, errors.Wrap(err, "failed validating stateInfo message")
	}
	sID := &msp.SerializedIdentity{}
	if err := proto.Unmarshal(peer.Identity, sID); err != nil {
		return nil, errors.Wrap(err, "failed unmarshalling peer's identity")
	}
	return &Peer{
		Identity:         peer.Identity,
		StateInfoMessage: stateInfMsg,
		AliveMessage:     aliveMsg,
		MSPID:            sID.Mspid,
	}, nil
}

type endorsementDescriptor struct {
	endorsersByGroups map[string][]*Peer
	layouts           []map[string]int
}

// NewClient creates a new Client instance
func NewClient(createConnection Dialer, s Signer, signerCacheSize uint) *Client {
	return &Client{
		createConnection: createConnection,

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Verify the queried peer's MSP configuration (mspConfigPath, localMSPID) is complete and valid
  2. Re-enroll or re-issue the peer's identity (cryptogen or CA) if certs are corrupt or expired
  3. Ensure all Fabric components are on a compatible version so identity serialization matches
  4. Re-join the peer to the channel so gossip re-propagates a fresh valid membership record
  5. Retry discovery against another peer to rule out one faulty node

Example fix

// before (client code silently trusting discovery response)
resp, _ := client.Send(ctx, req)
// after
resp, err := client.Send(ctx, req)
if err != nil {
    if strings.Contains(err.Error(), "failed unmarshalling peer's identity") {
        logger.Warnf("peer %s returned a corrupt identity; excluding it", peerURL)
    }
    return nil, fmt.Errorf("discovery: %w", err)
}
Defensive patterns

Strategy: try-catch

Validate before calling

func peerIdentityLooksUsable(identity []byte) error {
    sID := &msp.SerializedIdentity{}
    if len(identity) == 0 { return errors.New("empty identity") }
    if err := proto.Unmarshal(identity, sID); err != nil { return err }
    if sID.Mspid == "" || len(sID.IdBytes) == 0 { return errors.New("identity missing mspid or cert") }
    return nil
}

Type guard

func hasValidSerializedIdentity(b []byte) bool {
    var sID msp.SerializedIdentity
    return len(b) > 0 && proto.Unmarshal(b, &sID) == nil && sID.Mspid != ""
}

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "failed unmarshalling peer's identity") {
        logger.Warnf("peer identity corrupt; excluding peer and retrying discovery")
        return retryAgainstOtherPeer(ctx)
    }
    return err
}

Prevention

When it happens

Trigger: endoserser flow (createEndorsementDescriptor): proto.Unmarshal(peer.Identity, sID) fails because the Identity byte slice in the peer's gossip membership data is empty, corrupted, or not a serialized MSP identity.

Common situations: Peer bootstrap with a broken/missing MSP config so it gossips a malformed identity; identity format change between Fabric versions (e.g. serialized identity vs. raw cert PEM); gossip state populated before MSP was fully initialized; network truncation.

Related errors


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