{"record":{"id":"07f0cb81599dc9b9","repo":"hyperledger/fabric","slug":"error-marshaling-proposalresponse","errorCode":null,"errorMessage":"error marshaling ProposalResponse","messagePattern":"error marshaling ProposalResponse","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/proputils.go","lineNumber":177,"sourceCode":"}\n\n// GetBytesChaincodeActionPayload get the bytes of ChaincodeActionPayload from\n// the message\nfunc GetBytesChaincodeActionPayload(cap *peer.ChaincodeActionPayload) ([]byte, error) {\n\tif cap == nil {\n\t\treturn nil, errors.New(\"error marshaling ChaincodeActionPayload: proto: Marshal called with nil\")\n\t}\n\tcapBytes, err := proto.Marshal(cap)\n\treturn capBytes, errors.Wrap(err, \"error marshaling ChaincodeActionPayload\")\n}\n\n// GetBytesProposalResponse gets proposal bytes response\nfunc GetBytesProposalResponse(pr *peer.ProposalResponse) ([]byte, error) {\n\tif pr == nil {\n\t\treturn nil, errors.New(\"error marshaling ProposalResponse: proto: Marshal called with nil\")\n\t}\n\trespBytes, err := proto.Marshal(pr)\n\treturn respBytes, errors.Wrap(err, \"error marshaling ProposalResponse\")\n}\n\n// GetBytesHeader get the bytes of Header from the message\nfunc GetBytesHeader(hdr *common.Header) ([]byte, error) {\n\tif hdr == nil {\n\t\treturn nil, errors.New(\"error marshaling Header: proto: Marshal called with nil\")\n\t}\n\tbytes, err := proto.Marshal(hdr)\n\treturn bytes, errors.Wrap(err, \"error marshaling Header\")\n}\n\n// GetBytesSignatureHeader get the bytes of SignatureHeader from the message\nfunc GetBytesSignatureHeader(hdr *common.SignatureHeader) ([]byte, error) {\n\tif hdr == nil {\n\t\treturn nil, errors.New(\"error marshaling SignatureHeader: proto: Marshal called with nil\")\n\t}\n\tbytes, err := proto.Marshal(hdr)\n\treturn bytes, errors.Wrap(err, \"error marshaling SignatureHeader\")","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/proputils.go#L159-L195","documentation":"This is the wrapped error from proto.Marshal inside GetBytesProposalResponse for a non-nil ProposalResponse whose serialization failed. errors.Wrap adds the 'error marshaling ProposalResponse' context to the underlying proto error.","triggerScenarios":"proto.Marshal returning an error on a populated *peer.ProposalResponse — most often a codegen/runtime mismatch or a struct populated via reflection/decoding of invalid bytes.","commonSituations":"Dependency upgrades leaving fabric-protos-go and gogo/protobuf inconsistent, or ProposalResponses reconstructed from raw network bytes of unknown validity.","solutions":["Inspect errors.Cause(err) for the actual proto failure.","Pin consistent versions of fabric-protos-go and the proto runtime; rebuild.","Rebuild the ProposalResponse via the generated constructors/API rather than manual decoding.","If the pointer was actually nil, add the nil guard from the 'Marshal called with nil' variant."],"exampleFix":"// before\nprBytes, err := protoutil.GetBytesProposalResponse(pr)\nif err != nil {\n    return err\n}\n// after\nprBytes, err := protoutil.GetBytesProposalResponse(pr)\nif err != nil {\n    return errors.Wrap(errors.Cause(err), \"cannot serialize ProposalResponse\")\n}","handlingStrategy":"try-catch","validationCode":"if pr == nil {\n    return nil, errors.New(\"ProposalResponse is nil\")\n}","typeGuard":"func isSerializableProposalResponse(pr *peer.ProposalResponse) bool {\n    return pr != nil\n}","tryCatchPattern":"prBytes, err := protoutil.GetBytesProposalResponse(pr)\nif err != nil {\n    return nil, errors.Wrap(errors.Cause(err), \"ProposalResponse serialization failed\")\n}","preventionTips":["Unwrap wrapped errors to expose the real proto cause when debugging.","Pin matching versions of fabric-protos-go, fabric, and gogo/protobuf.","Serialize only ProposalResponses produced by the SDK/protoutil pipeline."],"tags":["grpc","protobuf","serialization","endorsement","hyperledger-fabric"],"backgroundTag":"proto-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"}