hyperledger/fabric · error
proto: Marshal called with nil
Error message
proto: Marshal called with nil
What it means
MockSignedEndorserProposalOrPanic test helper panic: CreateChaincodeProposal returned a nil proposal without an error, so marshalling it would panic in proto.Marshal. The helper converts this impossible-but-detected condition into an explicit panic with the sentinel text 'proto: Marshal called with nil'.
Source
Thrown at protoutil/txutils.go:395
// passed arguments
func MockSignedEndorserProposalOrPanic(
channelID string,
cs *peer.ChaincodeSpec,
creator,
signature []byte,
) (*peer.SignedProposal, *peer.Proposal) {
prop, _, err := CreateChaincodeProposal(
common.HeaderType_ENDORSER_TRANSACTION,
channelID,
&peer.ChaincodeInvocationSpec{ChaincodeSpec: cs},
creator,
)
if err != nil {
panic(err)
}
if prop == nil {
panic(errors.New("proto: Marshal called with nil"))
}
propBytes, err := proto.Marshal(prop)
if err != nil {
panic(err)
}
return &peer.SignedProposal{ProposalBytes: propBytes, Signature: signature}, prop
}
func MockSignedEndorserProposal2OrPanic(
channelID string,
cs *peer.ChaincodeSpec,
signer Signer,
) (*peer.SignedProposal, *peer.Proposal) {
serializedSigner, err := signer.Serialize()
if err != nil {
panic(err)
}View on GitHub (pinned to 2736b63f8f)
Solutions
- Fix CreateChaincodeProposal to never return (nil, nil)
- Adjust the test inputs (channel/chaincode spec) so proposal creation succeeds
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at protoutil/txutils.go:395 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/9e55232d25263810.
Report an issue: GitHub.