{"record":{"id":"0d6dd3a0677942aa","repo":"hyperledger/fabric","slug":"nil-payload-data","errorCode":null,"errorMessage":"nil payload data","messagePattern":"nil payload data","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/tx/endorser/parser.go","lineNumber":55,"sourceCode":"\tVersion      int32\n\tEpoch        uint64\n\tNonce        []byte\n}\n\nfunc unmarshalEndorserTx(txenv *tx.Envelope) (*EndorserTx, error) {\n\tif len(txenv.ChannelHeader.Extension) == 0 {\n\t\treturn nil, errors.New(\"empty header extension\")\n\t}\n\n\thdrExt, err := protoutil.UnmarshalChaincodeHeaderExtension(\n\t\ttxenv.ChannelHeader.Extension,\n\t)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(txenv.Data) == 0 {\n\t\treturn nil, errors.New(\"nil payload data\")\n\t}\n\n\ttx, err := protoutil.UnmarshalTransaction(txenv.Data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif len(tx.GetActions()) != 1 {\n\t\treturn nil, errors.Errorf(\"only one transaction action is supported, %d were present\", len(tx.GetActions()))\n\t}\n\n\ttxAction := tx.GetActions()[0]\n\n\tif txAction == nil {\n\t\treturn nil, errors.New(\"nil action\")\n\t}\n\n\tif len(txAction.Payload) == 0 {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/tx/endorser/parser.go#L37-L73","documentation":"unmarshalEndorserTx parses an envelope into an EndorserTx. After unmarshaling the envelope, the transaction payload bytes (txenv.Data) are absent. Hyperledger Fabric requires the envelope to carry a serialized Transaction containing at least one action; an empty Data field means the envelope is malformed or not an endorser transaction. The library fails fast here instead of returning a uselessly empty transaction.","triggerScenarios":"Calling UnmarshalEndorserTxAndValidate with an envelope whose TransactionActions/Data field is empty — e.g. an envelope created from a config transaction, a nil transaction, or a hand-built envelope where the Transaction was never assigned to Data.","commonSituations":"Passing a config/block-envelope rather than an endorser tx envelope; constructing protoutil envelopes manually and forgetting to set Data; corruption or truncation in storage/transport that dropped the payload.","solutions":["Verify the envelope is an endorser transaction envelope (Data non-empty) before calling UnmarshalEndorserTxAndValidate.","Re-create the envelope using protoutil.CreateTxEnvelope / the normal submit path instead of hand-building it.","If the envelope comes from a block, confirm it is an endorser tx (type TRANSACTION), not a config tx."],"exampleFix":"// before\nenv := &common.Envelope{Signature: sig} // Data never set\n_, err := parser.UnmarshalEndorserTxAndValidate(env)\n// after\npayload := protoutil.MarshalOrPanic(&common.Payload{Data: txBytes})\nenv := &common.Envelope{Payload: payload, Signature: sig}\n_, err := parser.UnmarshalEndorserTxAndValidate(env)","handlingStrategy":"validation","validationCode":"func hasTxData(env *common.Envelope) bool {\n    payload := &common.Payload{}\n    if proto.Unmarshal(env.GetPayload(), payload) != nil {\n        return false\n    }\n    return len(payload.GetData()) > 0\n}\n// call before: if !hasTxData(env) { skip UnmarshalEndorserTxAndValidate }","typeGuard":"func isValidEndorserEnvelope(env *common.Envelope) bool {\n    return env != nil && len(env.Payload) > 0\n}","tryCatchPattern":"tx, err := parser.UnmarshalEndorserTxAndValidate(env)\nif err != nil {\n    if strings.Contains(err.Error(), \"nil payload data\") {\n        // handle non-endorser/malformed envelope: skip or re-route\n        return nil\n    }\n    return err\n}","preventionTips":["Use protoutil.CreateTxEnvelope rather than hand-building envelopes.","Check envelope type (TRANSACTION vs CONFIG) before parsing.","Log the envelope type/length when this parse fails to diagnose input source."],"tags":["hyperledger-fabric","transaction","validation"],"backgroundTag":"malformed-envelope-payload","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"}