{"record":{"id":"218804155171ab4c","repo":"hyperledger/fabric","slug":"failed-to-deserialize-proposal-response-payload","errorCode":null,"errorMessage":"failed to deserialize proposal response payload","messagePattern":"failed to deserialize proposal response payload","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pkg/gateway/evaluate.go","lineNumber":160,"sourceCode":"\tif spec.GetChaincodeSpec() == nil {\n\t\treturn \"\", \"\", false, fmt.Errorf(\"no chaincode spec is provided, channel id [%s]\", channelHeader.GetChannelId())\n\t}\n\n\tif spec.GetChaincodeSpec().GetChaincodeId() == nil {\n\t\treturn \"\", \"\", false, fmt.Errorf(\"no chaincode id is provided, channel id [%s]\", channelHeader.GetChannelId())\n\t}\n\n\tif len(spec.GetChaincodeSpec().GetChaincodeId().GetName()) == 0 {\n\t\treturn \"\", \"\", false, fmt.Errorf(\"no chaincode name is provided, channel id [%s]\", channelHeader.GetChannelId())\n\t}\n\n\treturn channelHeader.GetChannelId(), spec.GetChaincodeSpec().GetChaincodeId().GetName(), len(payload.TransientMap) > 0, nil\n}\n\nfunc getResultFromProposalResponse(proposalResponse *peer.ProposalResponse) ([]byte, error) {\n\tresponsePayload := &peer.ProposalResponsePayload{}\n\tif err := proto.Unmarshal(proposalResponse.GetPayload(), responsePayload); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to deserialize proposal response payload\")\n\t}\n\n\treturn getResultFromProposalResponsePayload(responsePayload)\n}\n\nfunc getResultFromProposalResponsePayload(responsePayload *peer.ProposalResponsePayload) ([]byte, error) {\n\tchaincodeAction := &peer.ChaincodeAction{}\n\tif err := proto.Unmarshal(responsePayload.GetExtension(), chaincodeAction); err != nil {\n\t\treturn nil, errors.Wrap(err, \"failed to deserialize chaincode action\")\n\t}\n\n\treturn chaincodeAction.GetResponse().GetPayload(), nil\n}\n","sourceCodeStart":142,"sourceCodeEnd":174,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/pkg/gateway/evaluate.go#L142-L174","documentation":"getResultFromProposalResponse wraps errors from proto.Unmarshal of the proposal response's payload bytes into a peer.ProposalResponsePayload. This indicates the response bytes returned by the peer (or supplied by the caller) are not a valid protobuf-encoded ProposalResponsePayload — corruption, truncation, or the wrong message type was serialized.","triggerScenarios":"gateway Evaluate receives a ProposalResponse whose GetPayload() bytes fail proto.Unmarshal; typically when a caller constructs/supplies the proposal response manually, or bytes were corrupted/truncated in transit or storage.","commonSituations":"Manually assembling or replaying stored proposal responses; passing the wrong field (e.g. the envelope bytes) as the payload; mixing protobuf versions or message types across SDKs; reading responses from a tampered or old serialized cache.","solutions":["Verify the response comes from a real peer via the SDK rather than hand-built bytes","Ensure you pass proposalResponse.Payload (the ProposalResponse payload field), not envelope or response bytes","Re-run the evaluation/endorsement to get a fresh response if bytes may be stale or corrupted","Confirm proto message types match the Fabric peer protos version in use"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if len(proposalResponse.GetPayload()) == 0 {\n    return fmt.Errorf(\"proposal response payload is empty; cannot deserialize\")\n}","typeGuard":"func isParseableProposalResponsePayload(b []byte) bool {\n    p := &peer.ProposalResponsePayload{}\n    return proto.Unmarshal(b, p) == nil\n}","tryCatchPattern":"payload, err := getResultFromProposalResponse(pr)\nif err != nil {\n    var unwrap errors.Wrapped\n    if errors.As(err, &unwrap) { log.Printf(\"unmarshal cause: %v\", errors.Unwrap(err)) }\n    return fmt.Errorf(\"peer returned invalid payload, re-run evaluation: %w\", err)\n}","preventionTips":["Use real peer responses; do not serialize custom or placeholder bytes into Payload","Keep Fabric proto definitions and SDK versions aligned","Check protobuf truncation when persisting/replaying responses"],"tags":["fabric","gateway","protobuf","deserialization"],"backgroundTag":"protobuf-deserialization-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"}