hyperledger/fabric · error
failed to unmarshal proposal response's response payload as
Error message
failed to unmarshal proposal response's response payload as type %T
What it means
printResponseAsJSON takes the payload from the endorser's proposal response and unmarshals it into the expected protobuf message type. If proto.Unmarshal fails — the bytes are not a valid encoding of the given msg type — the error is wrapped with this message including the Go type (%T).
Source
Thrown at internal/peer/lifecycle/chaincode/common.go:125
return policyBytes, nil
}
func createCollectionConfigPackage(collectionsConfigFile string) (*pb.CollectionConfigPackage, error) {
var ccp *pb.CollectionConfigPackage
if collectionsConfigFile != "" {
var err error
ccp, _, err = chaincode.GetCollectionConfigFromFile(collectionsConfigFile)
if err != nil {
return nil, errors.WithMessagef(err, "invalid collection configuration in file %s", collectionsConfigFile)
}
}
return ccp, nil
}
func printResponseAsJSON(proposalResponse *pb.ProposalResponse, msg proto.Message, out io.Writer) error {
err := proto.Unmarshal(proposalResponse.Response.Payload, msg)
if err != nil {
return errors.Wrapf(err, "failed to unmarshal proposal response's response payload as type %T", msg)
}
bytes, err := json.MarshalIndent(msg, "", "\t")
if err != nil {
return errors.Wrap(err, "failed to marshal output")
}
fmt.Fprintf(out, "%s\n", string(bytes))
return nil
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Verify peer and CLI are on compatible fabric versions (lifecycle API mismatch)
- Inspect the wrapped error for the unmarshal cause and hex-dump the payload if debugging a custom endorser
- Retry against the correct endorser/peer (ensure not hitting an unexpected service on that host:port)
Example fix
// before resp from mismatched peer (fabric 1.4 style payload) // after upgrade peer to fabric 2.x so QueryApprovedChaincodeDefinition payloads match the expected proto message
Defensive patterns
Strategy: try-catch
Validate before calling
if len(proposalResponse.Response.Payload) == 0 {
return errors.New("endorser returned empty payload")
} Try / catch
if err := printResponseAsJSON(resp, msg, out); err != nil {
if strings.Contains(err.Error(), "failed to unmarshal proposal response's response payload") {
// check peer/CLI fabric version compatibility
}
return err
} Prevention
- Run matching fabric versions across peers and CLI (lifecycle APIs are version-sensitive)
- Avoid custom/intercepting endorsers that change payload formats
- Keep proto message definitions in sync with the peer's
When it happens
Trigger: Lifecycle commands (Approve/Commit/Get/Query etc.) receive a proposal response whose Response.Payload bytes cannot be decoded into the expected message (e.g. QueryInstalledChaincodesResult, ApproveChaincodeDefinitionResult).
Common situations: Peer at an incompatible fabric version returning a different payload schema; a proxy/middleware altering or truncating payloads; custom endorser returning non-protobuf bytes.
Related errors
- error unmarshalling
- error unmarshalling original config
- error unmarshalling updated config
- failed to unmarshal ApplicationPolicy bytes
- could not unmarshal signature policy envelope
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/d5619d4c83832f32.
Report an issue: GitHub.