{"record":{"id":"d5619d4c83832f32","repo":"hyperledger/fabric","slug":"failed-to-unmarshal-proposal-response-s-response-p-d5619d","errorCode":null,"errorMessage":"failed to unmarshal proposal response's response payload as type %T","messagePattern":"failed to unmarshal proposal response's response payload as type %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/common.go","lineNumber":125,"sourceCode":"\treturn policyBytes, nil\n}\n\nfunc createCollectionConfigPackage(collectionsConfigFile string) (*pb.CollectionConfigPackage, error) {\n\tvar ccp *pb.CollectionConfigPackage\n\tif collectionsConfigFile != \"\" {\n\t\tvar err error\n\t\tccp, _, err = chaincode.GetCollectionConfigFromFile(collectionsConfigFile)\n\t\tif err != nil {\n\t\t\treturn nil, errors.WithMessagef(err, \"invalid collection configuration in file %s\", collectionsConfigFile)\n\t\t}\n\t}\n\treturn ccp, nil\n}\n\nfunc printResponseAsJSON(proposalResponse *pb.ProposalResponse, msg proto.Message, out io.Writer) error {\n\terr := proto.Unmarshal(proposalResponse.Response.Payload, msg)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to unmarshal proposal response's response payload as type %T\", msg)\n\t}\n\n\tbytes, err := json.MarshalIndent(msg, \"\", \"\\t\")\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"failed to marshal output\")\n\t}\n\n\tfmt.Fprintf(out, \"%s\\n\", string(bytes))\n\n\treturn nil\n}\n","sourceCodeStart":107,"sourceCodeEnd":137,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/common.go#L107-L137","documentation":"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).","triggerScenarios":"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).","commonSituations":"Peer at an incompatible fabric version returning a different payload schema; a proxy/middleware altering or truncating payloads; custom endorser returning non-protobuf bytes.","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)"],"exampleFix":"// before\nresp from mismatched peer (fabric 1.4 style payload)\n// after\nupgrade peer to fabric 2.x so QueryApprovedChaincodeDefinition payloads match the expected proto message","handlingStrategy":"try-catch","validationCode":"if len(proposalResponse.Response.Payload) == 0 {\n    return errors.New(\"endorser returned empty payload\")\n}","typeGuard":null,"tryCatchPattern":"if err := printResponseAsJSON(resp, msg, out); err != nil {\n    if strings.Contains(err.Error(), \"failed to unmarshal proposal response's response payload\") {\n        // check peer/CLI fabric version compatibility\n    }\n    return err\n}","preventionTips":["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"],"tags":["fabric","protobuf","unmarshal","version-compatibility"],"backgroundTag":"payload-unmarshal-failed","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"}