{"record":{"id":"de5e698712097760","repo":"hyperledger/fabric","slug":"failed-unmarshalling-gossip-envelope-to-state-info","errorCode":null,"errorMessage":"failed unmarshalling gossip envelope to state info message","messagePattern":"failed unmarshalling gossip envelope to state info message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/client/client.go","lineNumber":541,"sourceCode":"\t\t\tendorsers = append(endorsers, peer)\n\t\t}\n\t\tdescriptor.endorsersByGroups[grp] = endorsers\n\t}\n\n\treturn descriptor, nil\n}\n\nfunc endorser(peer *discovery.Peer, chaincode, channel string) (*Peer, error) {\n\tif peer.MembershipInfo == nil || peer.StateInfo == nil {\n\t\treturn nil, errors.Errorf(\"received empty envelope(s) for endorsers for chaincode %s, channel %s\", chaincode, channel)\n\t}\n\taliveMsg, err := gprotoext.EnvelopeToGossipMessage(peer.MembershipInfo)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed unmarshalling gossip envelope to alive message\")\n\t}\n\tstateInfMsg, err := gprotoext.EnvelopeToGossipMessage(peer.StateInfo)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed unmarshalling gossip envelope to state info message\")\n\t}\n\tif err := validateAliveMessage(aliveMsg); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed validating alive message\")\n\t}\n\tif err := validateStateInfoMessage(stateInfMsg); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed validating stateInfo message\")\n\t}\n\tsID := &msp.SerializedIdentity{}\n\tif err := proto.Unmarshal(peer.Identity, sID); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed unmarshalling peer's identity\")\n\t}\n\treturn &Peer{\n\t\tIdentity:         peer.Identity,\n\t\tStateInfoMessage: stateInfMsg,\n\t\tAliveMessage:     aliveMsg,\n\t\tMSPID:            sID.Mspid,\n\t}, nil\n}","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/client/client.go#L523-L559","documentation":"When converting the peer's StateInfo envelope to a SignedGossipMessage via gprotoext.EnvelopeToGossipMessage fails, the error is wrapped as \"failed unmarshalling gossip envelope to state info message\". The StateInfo payload bytes are invalid or not actually a StateInfo gossip message, so the client cannot determine the peer's ledger height/state on the channel.","triggerScenarios":"discovery.Peer.StateInfo payload fails EnvelopeToGossipMessage while building an endorser for a channel chaincode query — payload not a valid GossipMessage of StateInfo type.","commonSituations":"Peer that published partial/invalid state data; Fabric proto version skew between discovery client and server; corrupted discovery response cached on the peer; mixing data from local membership (no StateInfo) into channel queries.","solutions":["Unwrap the inner error for the specific unmarshal/type failure","Ensure the discovery client and peers run compatible Fabric versions","Retry the query for fresh StateInfo after the peer finishes joining the channel","Inspect peer gossip logs for StateInfo publication errors","Exclude/restart the offending peer if it consistently returns bad StateInfo"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if p.StateInfo == nil || len(p.StateInfo.Payload) == 0 {\n\treturn errors.New(\"peer stateInfo payload is empty\")\n}","typeGuard":null,"tryCatchPattern":"_, err := endorser(p, cc, channel)\nif err != nil && strings.Contains(err.Error(), \"state info message\") {\n\t// peer state data invalid; re-query after stabilization\n\ttime.Sleep(3 * time.Second)\n\treturn refreshDiscoveryAndRetry(ctx)\n}","preventionTips":["Ensure peers publish StateInfo (fully joined) before discovery","Align Fabric versions to avoid proto skew","Clear stale discovery state after peer restarts","Inspect gossip logs for StateInfo publication errors"],"tags":["hyperledger-fabric","gossip","stateinfo","unmarshalling"],"backgroundTag":"gossip-envelope-unmarshal-failed","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}