{"record":{"id":"404aa86f3db925a5","repo":"hyperledger/fabric","slug":"error-unmarshalling-proposal","errorCode":null,"errorMessage":"error unmarshalling Proposal","messagePattern":"error unmarshalling Proposal","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/unmarshalers.go","lineNumber":151,"sourceCode":"// UnmarshalChaincodeEvents unmarshals bytes to a ChaincodeEvent\nfunc UnmarshalChaincodeEvents(eBytes []byte) (*peer.ChaincodeEvent, error) {\n\tchaincodeEvent := &peer.ChaincodeEvent{}\n\terr := proto.Unmarshal(eBytes, chaincodeEvent)\n\treturn chaincodeEvent, errors.Wrap(err, \"error unmarshalling ChaicnodeEvent\")\n}\n\n// UnmarshalProposalResponsePayload unmarshals bytes to a ProposalResponsePayload\nfunc UnmarshalProposalResponsePayload(prpBytes []byte) (*peer.ProposalResponsePayload, error) {\n\tprp := &peer.ProposalResponsePayload{}\n\terr := proto.Unmarshal(prpBytes, prp)\n\treturn prp, errors.Wrap(err, \"error unmarshalling ProposalResponsePayload\")\n}\n\n// UnmarshalProposal unmarshals bytes to a Proposal\nfunc UnmarshalProposal(propBytes []byte) (*peer.Proposal, error) {\n\tprop := &peer.Proposal{}\n\terr := proto.Unmarshal(propBytes, prop)\n\treturn prop, errors.Wrap(err, \"error unmarshalling Proposal\")\n}\n\n// UnmarshalTransaction unmarshals bytes to a Transaction\nfunc UnmarshalTransaction(txBytes []byte) (*peer.Transaction, error) {\n\ttx := &peer.Transaction{}\n\terr := proto.Unmarshal(txBytes, tx)\n\treturn tx, errors.Wrap(err, \"error unmarshalling Transaction\")\n}\n\n// UnmarshalChaincodeActionPayload unmarshals bytes to a ChaincodeActionPayload\nfunc UnmarshalChaincodeActionPayload(capBytes []byte) (*peer.ChaincodeActionPayload, error) {\n\tcap := &peer.ChaincodeActionPayload{}\n\terr := proto.Unmarshal(capBytes, cap)\n\treturn cap, errors.Wrap(err, \"error unmarshalling ChaincodeActionPayload\")\n}\n\n// UnmarshalChaincodeProposalPayload unmarshals bytes to a ChaincodeProposalPayload\nfunc UnmarshalChaincodeProposalPayload(bytes []byte) (*peer.ChaincodeProposalPayload, error) {","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/unmarshalers.go#L133-L169","documentation":"Returned by protoutil.UnmarshalProposal when proto.Unmarshal cannot decode bytes into a peer.Proposal message. The wrapper names the failing message type. It means the proposal bytes (typically ProposalBytes from a SignedProposal) are invalid, truncated, or of another message type.","triggerScenarios":"Calling UnmarshalProposal on SignedProposal.ProposalBytes that are empty or corrupted, on bytes of a different message (e.g. a Header), or proposals built by an SDK with mismatched protobuf definitions; reached from CheckACL, getSignedData, UnpackProposal, validateProposal, and CheckPolicy.","commonSituations":"Custom proposal submitter sending malformed SignedProposals (bad gRPC framing, byte-slice copies); peer-side ACL/policy validation of client requests; version drift between fabric-sdk-node/go and peer.","solutions":["Verify the client marshals peer.Proposal into SignedProposal.ProposalBytes (via protoutil.MarshalOrPanic / CreateProposal) before signing.","Confirm len(propBytes) > 0 and that signature verification passes before unmarshaling.","Align SDK and peer Fabric versions so the Proposal schema matches.","Check that the bytes are the proposal itself, not the signature or header slice.","Reject the request with a descriptive error (Bad Request) so clients can fix their submission."],"exampleFix":"// before\nprop, _ := protoutil.UnmarshalProposal(signedProp.Signature) // signature bytes, wrong field\n// after\nprop, err := protoutil.UnmarshalProposal(signedProp.ProposalBytes)\nif err != nil {\n    return status.Errorf(codes.InvalidArgument, \"malformed proposal: %v\", err)\n}","handlingStrategy":"try-catch","validationCode":"func validSignedProposal(sp *peer.SignedProposal) bool {\n    return sp != nil && len(sp.ProposalBytes) > 0 && len(sp.Signature) > 0\n}","typeGuard":"func isProposal(v any) bool {\n    _, ok := v.(*peer.Proposal)\n    return ok\n}","tryCatchPattern":"prop, err := protoutil.UnmarshalProposal(sp.ProposalBytes)\nif err != nil {\n    return status.Errorf(codes.InvalidArgument, \"malformed proposal: %v\", err)\n}","preventionTips":["Build proposals with protoutil.CreateProposal so ProposalBytes are a marshaled peer.Proposal","Verify signatures before/after unmarshal and return InvalidArgument on failure","Confirm clients pass ProposalBytes, not the Signature field","Keep fabric-sdk and peer versions consistent"],"tags":["fabric","protobuf","unmarshal","proposal"],"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"}