{"record":{"id":"41fda88e3ccbb5df","repo":"hyperledger/fabric","slug":"error-unmarshalling-proposalresponsepayload","errorCode":null,"errorMessage":"error unmarshalling ProposalResponsePayload","messagePattern":"error unmarshalling ProposalResponsePayload","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/unmarshalers.go","lineNumber":144,"sourceCode":"// UnmarshalResponse unmarshals bytes to a Response\nfunc UnmarshalResponse(resBytes []byte) (*peer.Response, error) {\n\tresponse := &peer.Response{}\n\terr := proto.Unmarshal(resBytes, response)\n\treturn response, errors.Wrap(err, \"error unmarshalling Response\")\n}\n\n// UnmarshalChaincodeEvents unmarshals bytes to a ChaincodeEvent\nfunc UnmarshalChaincodeEvents(eBytes []byte) (*peer.ChaincodeEvent, error) {\n\tchaincodeEvent := &peer.ChaincodeEvent{}\n\terr := proto.Unmarshal(eBytes, chaincodeEvent)\n\treturn chaincodeEvent, errors.Wrap(err, \"error unmarshalling ChaicnodeEvent\")\n}\n\n// UnmarshalProposalResponsePayload unmarshals bytes to a ProposalResponsePayload\nfunc UnmarshalProposalResponsePayload(prpBytes []byte) (*peer.ProposalResponsePayload, error) {\n\tprp := &peer.ProposalResponsePayload{}\n\terr := proto.Unmarshal(prpBytes, prp)\n\treturn prp, errors.Wrap(err, \"error unmarshalling ProposalResponsePayload\")\n}\n\n// UnmarshalProposal unmarshals bytes to a Proposal\nfunc UnmarshalProposal(propBytes []byte) (*peer.Proposal, error) {\n\tprop := &peer.Proposal{}\n\terr := proto.Unmarshal(propBytes, prop)\n\treturn prop, errors.Wrap(err, \"error unmarshalling Proposal\")\n}\n\n// UnmarshalTransaction unmarshals bytes to a Transaction\nfunc UnmarshalTransaction(txBytes []byte) (*peer.Transaction, error) {\n\ttx := &peer.Transaction{}\n\terr := proto.Unmarshal(txBytes, tx)\n\treturn tx, errors.Wrap(err, \"error unmarshalling Transaction\")\n}\n\n// UnmarshalChaincodeActionPayload unmarshals bytes to a ChaincodeActionPayload\nfunc UnmarshalChaincodeActionPayload(capBytes []byte) (*peer.ChaincodeActionPayload, error) {","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/unmarshalers.go#L126-L162","documentation":"Returned by protoutil.UnmarshalProposalResponsePayload when proto.Unmarshal cannot decode bytes into a peer.ProposalResponsePayload. The wrapper adds message-type context to the protobuf error. It means the payload bytes (proposal hash + extension) are not a valid ProposalResponsePayload encoding.","triggerScenarios":"Calling UnmarshalProposalResponsePayload on the Result field of a TransactionAction that is empty, truncated, or of another type; reached from transaction validation (validateEndorserTransaction, extractDependenciesForTx, ValidateLSCCInvocation) and endorsement processing.","commonSituations":"VSCC-style validation of committed transactions where action results were corrupted; parsing transactions from a different Fabric version; extracting the wrong field (action vs payload) in custom block parsers.","solutions":["Ensure you pass Cap.Action.ProposalResponsePayload (the action's Result field), not envelope/payload-level bytes.","Verify parent structures unmarshal successfully first (Envelope -> Payload -> Transaction).","Check non-empty, non-truncated input; log length and base64 of failing bytes.","Align Fabric versions between the peer that produced the transaction and the parser.","Fail the transaction validation cleanly with context instead of proceeding on a zero-value payload."],"exampleFix":"// before\nprp, _ := protoutil.UnmarshalProposalResponsePayload(env.Payload)\n// after\nact := tx.Actions[0].Payload\ncha, _ := protoutil.UnmarshalChaincodeActionPayload(act)\nprp, err := protoutil.UnmarshalProposalResponsePayload(cha.Action.ProposalResponsePayload)\nif err != nil {\n    return fmt.Errorf(\"bad proposal response payload: %w\", err)\n}","handlingStrategy":"validation","validationCode":"func validPRP(cha *peer.ChaincodeActionPayload) bool {\n    return cha != nil && cha.Action != nil && len(cha.Action.ProposalResponsePayload) > 0\n}","typeGuard":"func isProposalResponsePayload(v any) bool {\n    _, ok := v.(*peer.ProposalResponsePayload)\n    return ok\n}","tryCatchPattern":"prp, err := protoutil.UnmarshalProposalResponsePayload(cha.Action.ProposalResponsePayload)\nif err != nil {\n    return fmt.Errorf(\"invalid action payload (%d bytes): %w\", len(cha.Action.ProposalResponsePayload), err)\n}","preventionTips":["Drill down Envelope->Payload->Transaction->ChaincodeActionPayload before extracting Result","Never pass envelope/payload-level bytes to this API","Verify non-empty input and log lengths on failure","Align Fabric versions between producing peer and validating peer"],"tags":["fabric","protobuf","unmarshal","transaction","endorsement"],"backgroundTag":"protobuf-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"}