hyperledger/fabric · error
error unmarshalling Proposal
Error message
error unmarshalling Proposal
What it means
Returned by protoutil.UnmarshalProposal when proto.Unmarshal cannot decode bytes into a peer.Proposal message. The wrapper names the failing message type. It means the proposal bytes (typically ProposalBytes from a SignedProposal) are invalid, truncated, or of another message type.
Source
Thrown at protoutil/unmarshalers.go:151
// UnmarshalChaincodeEvents unmarshals bytes to a ChaincodeEvent
func UnmarshalChaincodeEvents(eBytes []byte) (*peer.ChaincodeEvent, error) {
chaincodeEvent := &peer.ChaincodeEvent{}
err := proto.Unmarshal(eBytes, chaincodeEvent)
return chaincodeEvent, errors.Wrap(err, "error unmarshalling ChaicnodeEvent")
}
// UnmarshalProposalResponsePayload unmarshals bytes to a ProposalResponsePayload
func UnmarshalProposalResponsePayload(prpBytes []byte) (*peer.ProposalResponsePayload, error) {
prp := &peer.ProposalResponsePayload{}
err := proto.Unmarshal(prpBytes, prp)
return prp, errors.Wrap(err, "error unmarshalling ProposalResponsePayload")
}
// UnmarshalProposal unmarshals bytes to a Proposal
func UnmarshalProposal(propBytes []byte) (*peer.Proposal, error) {
prop := &peer.Proposal{}
err := proto.Unmarshal(propBytes, prop)
return prop, errors.Wrap(err, "error unmarshalling Proposal")
}
// UnmarshalTransaction unmarshals bytes to a Transaction
func UnmarshalTransaction(txBytes []byte) (*peer.Transaction, error) {
tx := &peer.Transaction{}
err := proto.Unmarshal(txBytes, tx)
return tx, errors.Wrap(err, "error unmarshalling Transaction")
}
// UnmarshalChaincodeActionPayload unmarshals bytes to a ChaincodeActionPayload
func UnmarshalChaincodeActionPayload(capBytes []byte) (*peer.ChaincodeActionPayload, error) {
cap := &peer.ChaincodeActionPayload{}
err := proto.Unmarshal(capBytes, cap)
return cap, errors.Wrap(err, "error unmarshalling ChaincodeActionPayload")
}
// UnmarshalChaincodeProposalPayload unmarshals bytes to a ChaincodeProposalPayload
func UnmarshalChaincodeProposalPayload(bytes []byte) (*peer.ChaincodeProposalPayload, error) {View on GitHub (pinned to 2736b63f8f)
Solutions
- Verify the client marshals peer.Proposal into SignedProposal.ProposalBytes (via protoutil.MarshalOrPanic / CreateProposal) before signing.
- Confirm len(propBytes) > 0 and that signature verification passes before unmarshaling.
- Align SDK and peer Fabric versions so the Proposal schema matches.
- Check that the bytes are the proposal itself, not the signature or header slice.
- Reject the request with a descriptive error (Bad Request) so clients can fix their submission.
Example fix
// before
prop, _ := protoutil.UnmarshalProposal(signedProp.Signature) // signature bytes, wrong field
// after
prop, err := protoutil.UnmarshalProposal(signedProp.ProposalBytes)
if err != nil {
return status.Errorf(codes.InvalidArgument, "malformed proposal: %v", err)
} Defensive patterns
Strategy: try-catch
Validate before calling
func validSignedProposal(sp *peer.SignedProposal) bool {
return sp != nil && len(sp.ProposalBytes) > 0 && len(sp.Signature) > 0
} Type guard
func isProposal(v any) bool {
_, ok := v.(*peer.Proposal)
return ok
} Try / catch
prop, err := protoutil.UnmarshalProposal(sp.ProposalBytes)
if err != nil {
return status.Errorf(codes.InvalidArgument, "malformed proposal: %v", err)
} Prevention
- Build proposals with protoutil.CreateProposal so ProposalBytes are a marshaled peer.Proposal
- Verify signatures before/after unmarshal and return InvalidArgument on failure
- Confirm clients pass ProposalBytes, not the Signature field
- Keep fabric-sdk and peer versions consistent
When it happens
Trigger: Calling UnmarshalProposal on SignedProposal.ProposalBytes that are empty or corrupted, on bytes of a different message (e.g. a Header), or proposals built by an SDK with mismatched protobuf definitions; reached from CheckACL, getSignedData, UnpackProposal, validateProposal, and CheckPolicy.
Common situations: Custom proposal submitter sending malformed SignedProposals (bad gRPC framing, byte-slice copies); peer-side ACL/policy validation of client requests; version drift between fabric-sdk-node/go and peer.
Understand the failure class
Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.
Related errors
- error unmarshalling ChaincodeHeaderExtension
- error unmarshalling ChaincodeProposalPayload
- error unmarshalling
- error unmarshalling original config
- error unmarshalling updated config
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/404aa86f3db925a5.
Report an issue: GitHub.