{"record":{"id":"e80e3cfa38154de4","repo":"hyperledger/fabric","slug":"error-unmarshalling-transaction","errorCode":null,"errorMessage":"error unmarshalling Transaction","messagePattern":"error unmarshalling Transaction","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/proputils.go","lineNumber":204,"sourceCode":"\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\")\n}\n\n// GetBytesTransaction get the bytes of Transaction from the message\nfunc GetBytesTransaction(tx *peer.Transaction) ([]byte, error) {\n\tif tx == nil {\n\t\treturn nil, errors.New(\"error marshaling Transaction: proto: Marshal called with nil\")\n\t}\n\tbytes, err := proto.Marshal(tx)\n\treturn bytes, errors.Wrap(err, \"error unmarshalling Transaction\")\n}\n\n// GetBytesPayload get the bytes of Payload from the message\nfunc GetBytesPayload(payl *common.Payload) ([]byte, error) {\n\tif payl == nil {\n\t\treturn nil, errors.New(\"error marshaling Payload: proto: Marshal called with nil\")\n\t}\n\tbytes, err := proto.Marshal(payl)\n\treturn bytes, errors.Wrap(err, \"error marshaling Payload\")\n}\n\n// GetBytesEnvelope get the bytes of Envelope from the message\nfunc GetBytesEnvelope(env *common.Envelope) ([]byte, error) {\n\tif env == nil {\n\t\treturn nil, errors.New(\"error marshaling Envelope: proto: Marshal called with nil\")\n\t}\n\tbytes, err := proto.Marshal(env)\n\treturn bytes, errors.Wrap(err, \"error marshaling Envelope\")","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/proputils.go#L186-L222","documentation":"Wrapper error from GetBytesTransaction: the final proto.Marshal(tx) returned an error (note the copy-pasted message says 'unmarshalling' although this is a marshal path). It means Transaction bytes could not be produced for some reason other than the explicit nil guard, or it wraps the nil-marshal failure.","triggerScenarios":"proto.Marshal(tx) failing inside GetBytesTransaction for callers createSignedTxTwoActions, prepareTransaction, CreateSignedTx; typically a nil or invalid Transaction reaching the marshal call.","commonSituations":"Fabric SDK/test transaction assembly where an earlier step (GetPayloads, proposal response merging) failed but its error was ignored, leaving an unusable Transaction.","solutions":["Read the wrapped cause from the error chain to identify the real marshal failure","Ensure all TransactionActions were successfully created from ProposalResponses before marshaling","Fix upstream error handling so failures are surfaced before serialization"],"exampleFix":"// before\nbytes, err := proto.Marshal(tx)\nreturn bytes, errors.Wrap(err, \"error unmarshalling Transaction\") // misleading label\n// after\nbytes, err := proto.Marshal(tx)\nreturn bytes, errors.Wrap(err, \"error marshaling Transaction\")","handlingStrategy":"try-catch","validationCode":"if tx == nil || len(tx.Actions) == 0 {\n\treturn errors.New(\"invalid transaction: nil or no actions\")\n}","typeGuard":"func isSerializableTransaction(tx *peer.Transaction) bool {\n\treturn tx != nil && len(tx.Actions) > 0\n}","tryCatchPattern":"bytes, err := protoutil.GetBytesTransaction(tx)\nif err != nil {\n\treturn nil, fmt.Errorf(\"GetBytesTransaction failed: %w\", err)\n}","preventionTips":["Handle upstream errors from GetPayloads/CreateTransaction immediately","Don't ignore errors from earlier assembly steps; nils propagate downstream","Rename/copy-paste-check error strings to keep messages accurate"],"tags":["hyperledger-fabric","protobuf","serialization","wrapped-error"],"backgroundTag":"proto-marshal-nil-message","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"}