{"record":{"id":"d27c470a72c28b9a","repo":"hyperledger/fabric","slug":"failed-unmarshalling-gossipmessage-from-envelope","errorCode":null,"errorMessage":"Failed unmarshalling GossipMessage from envelope: %v","messagePattern":"Failed unmarshalling GossipMessage from envelope: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gossip/protoext/signing.go","lineNumber":67,"sourceCode":"\t}\n\tsMsg := &SignedGossipMessage{\n\t\tGossipMessage: m,\n\t}\n\t_, err := sMsg.Sign(signer)\n\treturn sMsg, err\n}\n\n// EnvelopeToGossipMessage un-marshals a given envelope and creates a\n// SignedGossipMessage out of it.\n// Returns an error if un-marshaling fails.\nfunc EnvelopeToGossipMessage(e *gossip.Envelope) (*SignedGossipMessage, error) {\n\tif e == nil {\n\t\treturn nil, errors.New(\"nil envelope\")\n\t}\n\tmsg := &gossip.GossipMessage{}\n\terr := proto.Unmarshal(e.Payload, msg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"Failed unmarshalling GossipMessage from envelope: %v\", err)\n\t}\n\treturn &SignedGossipMessage{\n\t\tGossipMessage: msg,\n\t\tEnvelope:      e,\n\t}, nil\n}\n\n// InternalEndpoint returns the internal endpoint in the secret envelope, or an\n// empty string if a failure occurs.\nfunc InternalEndpoint(s *gossip.SecretEnvelope) string {\n\tif s == nil {\n\t\treturn \"\"\n\t}\n\tsecret := &gossip.Secret{}\n\tif err := proto.Unmarshal(s.Payload, secret); err != nil {\n\t\treturn \"\"\n\t}\n\treturn secret.GetInternalEndpoint()","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/gossip/protoext/signing.go#L49-L85","documentation":"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).","triggerScenarios":"Calling EnvelopeToGossipMessage with an envelope whose Payload is empty or was produced by a different proto message type/version, or corrupted during transport/storage.","commonSituations":"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.","solutions":["Verify the envelope Payload was produced by proto.Marshal of a gossip.GossipMessage","Align fabric/proto versions between sender and receiver","Log the raw payload (hex) and inspect it to identify truncation or wrong message type"],"exampleFix":"// before\npayload := []byte(\"some non-proto data\")\nenvelope.Payload = payload\n// after\nb, _ := proto.Marshal(gossipMsg)\nenvelope.Payload = b","handlingStrategy":"try-catch","validationCode":"if len(env.Payload) == 0 {\n    return errors.New(\"envelope has empty payload\")\n}","typeGuard":"func hasPayload(e *gossip.Envelope) bool { return e != nil && len(e.Payload) > 0 }","tryCatchPattern":"msg, err := protoext.EnvelopeToGossipMessage(env)\nif err != nil {\n    return nil, fmt.Errorf(\"dropping undecodable envelope: %w\", err)\n}","preventionTips":["Marshal with proto.Marshal(gossip.GossipMessage) before wrapping in an envelope","Match fabric/proto versions on all peers","Log offending payloads for diagnosis before dropping"],"tags":["gossip","hyperledger-fabric","deserialization","protobuf"],"backgroundTag":"proto-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"}