hyperledger/fabric · error
error marshaling ChaincodeAction
Error message
error marshaling ChaincodeAction
What it means
GetBytesProposalResponsePayload assembles a ChaincodeAction (results, events, response, chaincode ID) and marshals it for inclusion in the ProposalResponsePayload. Marshal failure here is wrapped with this message; it should be practically impossible with well-formed peer protos, so treat it as a proto incompatibility signal.
Source
Thrown at protoutil/proputils.go:123
}
prop := &peer.Proposal{
Header: hdrBytes,
Payload: ccPropPayloadBytes,
}
return prop, txid, nil
}
// GetBytesProposalResponsePayload gets proposal response payload
func GetBytesProposalResponsePayload(hash []byte, response *peer.Response, result []byte, event []byte, ccid *peer.ChaincodeID) ([]byte, error) {
cAct := &peer.ChaincodeAction{
Events: event, Results: result,
Response: response,
ChaincodeId: ccid,
}
cActBytes, err := proto.Marshal(cAct)
if err != nil {
return nil, errors.Wrap(err, "error marshaling ChaincodeAction")
}
prp := &peer.ProposalResponsePayload{
Extension: cActBytes,
ProposalHash: hash,
}
prpBytes, err := proto.Marshal(prp)
return prpBytes, errors.Wrap(err, "error marshaling ProposalResponsePayload")
}
// GetBytesChaincodeProposalPayload gets the chaincode proposal payload
func GetBytesChaincodeProposalPayload(cpp *peer.ChaincodeProposalPayload) ([]byte, error) {
if cpp == nil {
return nil, errors.New("error marshaling ChaincodeProposalPayload: proto: Marshal called with nil")
}
cppBytes, err := proto.Marshal(cpp)
return cppBytes, errors.Wrap(err, "error marshaling ChaincodeProposalPayload")
}View on GitHub (pinned to 2736b63f8f)
Solutions
- Align fabric-protos-go versions across the endorser build (go mod tidy)
- Verify result ([]byte), event ([]byte), and response (*peer.Response) passed in are not corrupt
- Reproduce with a minimal CreateProposalResponse call to isolate the field
Defensive patterns
Strategy: validation
Validate before calling
cAct := &peer.ChaincodeAction{Results: result, Events: event, Response: response, ChaincodeId: ccid}
if _, err := proto.Marshal(cAct); err != nil {
return fmt.Errorf("ChaincodeAction not marshalable: %w", err)
} Type guard
func actionMarshalable(cAct *peer.ChaincodeAction) bool {
if cAct == nil { return false }
_, err := proto.Marshal(cAct)
return err == nil
} Try / catch
prpBytes, err := protoutil.GetBytesProposalResponsePayload(hash, result, event, response, ccid)
if err != nil {
return fmt.Errorf("endorsement aborted, marshal failure: %w", err)
} Prevention
- Keep fabric-protos-go versions consistent between endorser and plugins
- Verify result/event bytes originate from trusted chaincode runtime
- Add unit coverage for CreateProposalResponse in CI
When it happens
Trigger: Called by CreateProposalResponse, CreateProposalResponseFailure, TestProposalResponse, or ProcessProposalSuccessfullyOrError when the cAct message built from result/events/response/ccid fails proto.Marshal — only realistic with mismatched fabric-protos descriptors or corrupted registered types.
Common situations: Endorser builds with divergent fabric-protos-go versions; custom plugins returning corrupt Result/Response bytes; framework tests constructing non-standard messages.
Related errors
- could not marshal field %s
- failed to marshal updated readiness result
- failed to marshal args
- failed to marshal args
- failed to deserialize chaincode action
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/6d56716aec0edf52.
Report an issue: GitHub.