{"record":{"id":"8740316b54e10b2c","repo":"hyperledger/fabric","slug":"error-marshaling-chaincodeproposalpayload","errorCode":null,"errorMessage":"error marshaling ChaincodeProposalPayload","messagePattern":"error marshaling ChaincodeProposalPayload","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/proputils.go","lineNumber":76,"sourceCode":"\n// CreateChaincodeProposalWithTxIDNonceAndTransient creates a proposal from\n// given input\nfunc CreateChaincodeProposalWithTxIDNonceAndTransient(txid string, typ common.HeaderType, channelID string, cis *peer.ChaincodeInvocationSpec, nonce, creator []byte, transientMap map[string][]byte) (*peer.Proposal, string, error) {\n\tccHdrExt := &peer.ChaincodeHeaderExtension{ChaincodeId: cis.ChaincodeSpec.ChaincodeId}\n\tccHdrExtBytes, err := proto.Marshal(ccHdrExt)\n\tif err != nil {\n\t\treturn nil, \"\", errors.Wrap(err, \"error marshaling ChaincodeHeaderExtension\")\n\t}\n\n\tcisBytes, err := proto.Marshal(cis)\n\tif err != nil {\n\t\treturn nil, \"\", errors.Wrap(err, \"error marshaling ChaincodeInvocationSpec\")\n\t}\n\n\tccPropPayload := &peer.ChaincodeProposalPayload{Input: cisBytes, TransientMap: transientMap}\n\tccPropPayloadBytes, err := proto.Marshal(ccPropPayload)\n\tif err != nil {\n\t\treturn nil, \"\", errors.Wrap(err, \"error marshaling ChaincodeProposalPayload\")\n\t}\n\n\t// TODO: epoch is now set to zero. This must be changed once we\n\t// get a more appropriate mechanism to handle it in.\n\tvar epoch uint64\n\n\thdr := &common.Header{\n\t\tChannelHeader: MarshalOrPanic(\n\t\t\t&common.ChannelHeader{\n\t\t\t\tType:      int32(typ),\n\t\t\t\tTxId:      txid,\n\t\t\t\tTimestamp: timestamppb.Now(),\n\t\t\t\tChannelId: channelID,\n\t\t\t\tExtension: ccHdrExtBytes,\n\t\t\t\tEpoch:     epoch,\n\t\t\t},\n\t\t),\n\t\tSignatureHeader: MarshalOrPanic(","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/proputils.go#L58-L94","documentation":"The ChaincodeProposalPayload (marshaled invocation input + transient map) is serialized inside CreateChaincodeProposalWithTxIDNonceAndTransient; any proto.Marshal error is wrapped with this message. Practically it signals proto library/descriptor incompatibility or invalid input structure.","triggerScenarios":"Any wrapper call (CreateChaincodeProposalWithTransient, CreateChaincodeProposalWithTxIDAndTransient, CreateProposalFromCISAndTxid, ConstructSignedTxEnv) where marshaling &peer.ChaincodeProposalPayload{Input: cisBytes, TransientMap: transientMap} fails — only realistic with mismatched protobuf descriptors or a corrupted proto registry.","commonSituations":"Mixed fabric / fabric-protos-go versions in one binary; custom builds of protos; very large transient maps are NOT a cause (proto.Marshal has no size limit here) but corrupt keys could break expectations downstream.","solutions":["Reconcile fabric-protos-go and fabric versions (go mod tidy, single version per module graph)","Rebuild the binary after `go clean -cache` to clear stale compiled proto descriptors","Validate transient map keys are strings with []byte values (they are by type, so mostly inspect proto version)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"cpp := &peer.ChaincodeProposalPayload{Input: cisBytes, TransientMap: transientMap}\nif _, err := proto.Marshal(cpp); err != nil {\n\treturn fmt.Errorf(\"proposal payload not marshalable (check proto runtime alignment): %w\", err)\n}","typeGuard":"func payloadMarshalable(cpp *peer.ChaincodeProposalPayload) bool {\n\tif cpp == nil { return false }\n\t_, err := proto.Marshal(cpp)\n\treturn err == nil\n}","tryCatchPattern":"proposal, txid, err := protoutil.CreateChaincodeProposalWithTxIDAndTransient(txid, htype, ch, cis, creator, transient)\nif err != nil {\n\tif strings.Contains(err.Error(), \"marshaling\") {\n\t\treturn fmt.Errorf(\"proto incompatibility suspected: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Single google.golang.org/protobuf version across the module graph","Rebuild binaries after upgrading fabric-protos-go","CI smoke test: create and marshal a full proposal in a unit test"],"tags":["fabric","protobuf","marshal","proposal-payload"],"backgroundTag":"protobuf-marshal-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"}