{"record":{"id":"6d56716aec0edf52","repo":"hyperledger/fabric","slug":"error-marshaling-chaincodeaction","errorCode":null,"errorMessage":"error marshaling ChaincodeAction","messagePattern":"error marshaling ChaincodeAction","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/proputils.go","lineNumber":123,"sourceCode":"\t}\n\n\tprop := &peer.Proposal{\n\t\tHeader:  hdrBytes,\n\t\tPayload: ccPropPayloadBytes,\n\t}\n\treturn prop, txid, nil\n}\n\n// GetBytesProposalResponsePayload gets proposal response payload\nfunc GetBytesProposalResponsePayload(hash []byte, response *peer.Response, result []byte, event []byte, ccid *peer.ChaincodeID) ([]byte, error) {\n\tcAct := &peer.ChaincodeAction{\n\t\tEvents: event, Results: result,\n\t\tResponse:    response,\n\t\tChaincodeId: ccid,\n\t}\n\tcActBytes, err := proto.Marshal(cAct)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"error marshaling ChaincodeAction\")\n\t}\n\n\tprp := &peer.ProposalResponsePayload{\n\t\tExtension:    cActBytes,\n\t\tProposalHash: hash,\n\t}\n\tprpBytes, err := proto.Marshal(prp)\n\treturn prpBytes, errors.Wrap(err, \"error marshaling ProposalResponsePayload\")\n}\n\n// GetBytesChaincodeProposalPayload gets the chaincode proposal payload\nfunc GetBytesChaincodeProposalPayload(cpp *peer.ChaincodeProposalPayload) ([]byte, error) {\n\tif cpp == nil {\n\t\treturn nil, errors.New(\"error marshaling ChaincodeProposalPayload: proto: Marshal called with nil\")\n\t}\n\tcppBytes, err := proto.Marshal(cpp)\n\treturn cppBytes, errors.Wrap(err, \"error marshaling ChaincodeProposalPayload\")\n}","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/proputils.go#L105-L141","documentation":"GetBytesProposalResponsePayload assembles a ChaincodeAction (results, events, response, chaincode ID) and marshals it for inclusion in the ProposalResponsePayload. Marshal failure here is wrapped with this message; it should be practically impossible with well-formed peer protos, so treat it as a proto incompatibility signal.","triggerScenarios":"Called by CreateProposalResponse, CreateProposalResponseFailure, TestProposalResponse, or ProcessProposalSuccessfullyOrError when the cAct message built from result/events/response/ccid fails proto.Marshal — only realistic with mismatched fabric-protos descriptors or corrupted registered types.","commonSituations":"Endorser builds with divergent fabric-protos-go versions; custom plugins returning corrupt Result/Response bytes; framework tests constructing non-standard messages.","solutions":["Align fabric-protos-go versions across the endorser build (go mod tidy)","Verify result ([]byte), event ([]byte), and response (*peer.Response) passed in are not corrupt\n","Reproduce with a minimal CreateProposalResponse call to isolate the field"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"cAct := &peer.ChaincodeAction{Results: result, Events: event, Response: response, ChaincodeId: ccid}\nif _, err := proto.Marshal(cAct); err != nil {\n\treturn fmt.Errorf(\"ChaincodeAction not marshalable: %w\", err)\n}","typeGuard":"func actionMarshalable(cAct *peer.ChaincodeAction) bool {\n\tif cAct == nil { return false }\n\t_, err := proto.Marshal(cAct)\n\treturn err == nil\n}","tryCatchPattern":"prpBytes, err := protoutil.GetBytesProposalResponsePayload(hash, result, event, response, ccid)\nif err != nil {\n\treturn fmt.Errorf(\"endorsement aborted, marshal failure: %w\", err)\n}","preventionTips":["Keep fabric-protos-go versions consistent between endorser and plugins","Verify result/event bytes originate from trusted chaincode runtime","Add unit coverage for CreateProposalResponse in CI"],"tags":["fabric","protobuf","marshal","chaincode-action"],"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"}