{"record":{"id":"4a5149610383bde5","repo":"hyperledger/fabric","slug":"failed-unmarshalling-stateinfo-message","errorCode":null,"errorMessage":"failed unmarshalling stateInfo message","messagePattern":"failed unmarshalling stateInfo message","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/client/client.go","lineNumber":424,"sourceCode":"\n\t\tresp[key] = peers\n\t}\n\treturn nil\n}\n\nfunc peersForChannel(membersRes *discovery.PeerMembershipResult, qt protoext.QueryType) ([]*Peer, error) {\n\tvar peers []*Peer\n\tfor org, peersOfCurrentOrg := range membersRes.PeersByOrg {\n\t\tfor _, peer := range peersOfCurrentOrg.Peers {\n\t\t\taliveMsg, err := gprotoext.EnvelopeToGossipMessage(peer.MembershipInfo)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"failed unmarshalling alive message\")\n\t\t\t}\n\t\t\tvar stateInfoMsg *gprotoext.SignedGossipMessage\n\t\t\tif isStateInfoExpected(qt) {\n\t\t\t\tstateInfoMsg, err = gprotoext.EnvelopeToGossipMessage(peer.StateInfo)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, errors.Wrap(err, \"failed unmarshalling stateInfo message\")\n\t\t\t\t}\n\t\t\t\tif err := validateStateInfoMessage(stateInfoMsg); err != nil {\n\t\t\t\t\treturn nil, errors.Wrap(err, \"failed validating stateInfo message\")\n\t\t\t\t}\n\t\t\t}\n\t\t\tif err := validateAliveMessage(aliveMsg); err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"failed validating alive message\")\n\t\t\t}\n\t\t\tpeers = append(peers, &Peer{\n\t\t\t\tMSPID:            org,\n\t\t\t\tIdentity:         peer.Identity,\n\t\t\t\tAliveMessage:     aliveMsg,\n\t\t\t\tStateInfoMessage: stateInfoMsg,\n\t\t\t})\n\t\t}\n\t}\n\treturn peers, nil\n}","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/client/client.go#L406-L442","documentation":"Same as the alive-message error but for the StateInfo envelope: when the query type requires state info (e.g. chaincode or endorsement queries), the client parses peer.StateInfo into a SignedGossipMessage and wraps any parse failure with this message. The server returned a StateInfo envelope that is nil, truncated, or not a valid gossip message.","triggerScenarios":"A discovery request including a state-info-dependent query (ChaincodeQuery, EndorsementQuery, ConfigQuery paths where isStateInfoExpected(qt) is true) whose response entries contain invalid peer.StateInfo envelopes.","commonSituations":"Peer that has not yet joined/gossiped state info for the channel; version skew between client and peer protos; corrupted responses from a network middlebox; stale peer membership entries.","solutions":["Confirm the target peers have joined the channel and gossip state info is flowing (peer channel list, gossip logs).","Align client and peer versions/Fabric release.","Retry the discovery request; state info may have been transiently missing.","Validate TLS/network path for corruption.","Fall back to peers that returned valid state info."],"exampleFix":"// before\nres, _ := client.SendRequest(ctx, req) // req included chaincode query\n// after: catch and retry once against another peer\nres, err := client.SendRequest(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"failed unmarshalling stateInfo message\") {\n  res, err = client.SendRequest(ctx, reqWithAlternatePeers)\n}","handlingStrategy":"validation","validationCode":"func hasStateInfo(p *discovery.Peer) bool {\n  return p != nil && p.StateInfo != nil && len(p.StateInfo.Payload) > 0\n}","typeGuard":"func isStateInfoMessage(msg *gprotoext.SignedGossipMessage) bool {\n  return msg != nil && msg.IsStateInfoMsg()\n}","tryCatchPattern":"if err != nil {\n  if strings.Contains(err.Error(), \"failed unmarshalling stateInfo message\") {\n    return retryDiscovery(ctx, req) // transient: state info may arrive later\n  }\n  return err\n}","preventionTips":["Verify peers have joined the channel before discovery queries","Retry state-info-dependent queries once before failing","Match Fabric versions across the network","Check gossip state-info logs on peers"],"tags":["fabric","discovery","gossip","stateinfo","unmarshal"],"backgroundTag":"protobuf-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"}