{"record":{"id":"899b5bc6c8fa64ec","repo":"hyperledger/fabric","slug":"txrwset-fromprotobytes-error-s","errorCode":null,"errorMessage":"txRWSet.FromProtoBytes error %s","messagePattern":"txRWSet\\.FromProtoBytes error (.+?)","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":575,"sourceCode":"\t\tif !lscc.ChaincodeVersionRegExp.MatchString(ccVersion) {\n\t\t\treturn policyErr(errors.Errorf(\"invalid chaincode version '%s'\", ccVersion))\n\t\t}\n\n\t\t// get the rwset\n\t\tpRespPayload, err := protoutil.UnmarshalProposalResponsePayload(cap.Action.ProposalResponsePayload)\n\t\tif err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"GetProposalResponsePayload error %s\", err))\n\t\t}\n\t\tif pRespPayload.Extension == nil {\n\t\t\treturn policyErr(fmt.Errorf(\"nil pRespPayload.Extension\"))\n\t\t}\n\t\trespPayload, err := protoutil.UnmarshalChaincodeAction(pRespPayload.Extension)\n\t\tif err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"GetChaincodeAction error %s\", err))\n\t\t}\n\t\ttxRWSet := &rwsetutil.TxRwSet{}\n\t\tif err = txRWSet.FromProtoBytes(respPayload.Results); err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"txRWSet.FromProtoBytes error %s\", err))\n\t\t}\n\n\t\t// extract the rwset for lscc\n\t\tvar lsccrwset *kvrwset.KVRWSet\n\t\tfor _, ns := range txRWSet.NsRwSets {\n\t\t\tlogger.Debugf(\"Namespace %s\", ns.NameSpace)\n\t\t\tif ns.NameSpace == \"lscc\" {\n\t\t\t\tlsccrwset = ns.KvRwSet\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\t// retrieve from the ledger the entry for the chaincode at hand\n\t\tcdLedger, ccExistsOnLedger, err := vscc.getInstantiatedCC(chid, cdsArgs.ChaincodeSpec.ChaincodeId.Name)\n\t\tif err != nil {\n\t\t\treturn &commonerrors.VSCCExecutionFailureError{Err: err}\n\t\t}\n","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L557-L593","documentation":"VSCC converts respPayload.Results into a rwsetutil.TxRwSet via FromProtoBytes. This fails when the results bytes are not a valid TxReadWriteSet proto, meaning the endorsed write set is corrupt or of the wrong shape; the transaction is rejected with this policy error.","triggerScenarios":"An lscc transaction whose ChaincodeAction.Results bytes fail to decode into a valid transaction read/write set (empty, truncated, or incompatible kvrwset encoding).","commonSituations":"Peer/SDK proto drift (especially after Fabric version upgrades changing rwset messages), custom endorser code emitting malformed Results, or corrupted transactions from unreliable transports.","solutions":["Resubmit the transaction collected from healthy endorsers; inspect one reply locally with txRWSet.FromProtoBytes to confirm validity before signing.","Upgrade peer and SDK to the same Fabric version so rwset proto definitions match.","If running custom/modified endorser code, ensure Results is the marshaled TxReadWriteSet produced by the standard ledger simulation."],"exampleFix":"// before: manually stuffing kvrwset bytes into Results\nresults, _ := proto.Marshal(&kvrwset.KVRWSet{})\n// after: use the simulated TxReadWriteSet\nresults, _ := txRWSet.ToProtoBytes() // rwsetutil.TxRwSet","handlingStrategy":"validation","validationCode":"txRWSet := &rwsetutil.TxRwSet{}\nif err := txRWSet.FromProtoBytes(ca.Results); err != nil {\n    return fmt.Errorf(\"endorsed results are not a valid rwset: %v\", err)\n}","typeGuard":"func isValidRwsetBytes(b []byte) bool {\n    txRWSet := &rwsetutil.TxRwSet{}\n    return txRWSet.FromProtoBytes(b) == nil\n}","tryCatchPattern":"if err := txRWSet.FromProtoBytes(respPayload.Results); err != nil {\n    logger.Warnf(\"rwset decode failed (proto drift or corruption): %v\", err)\n    return policyErr(err)\n}","preventionTips":["Take Results directly from the ledger simulation (TxRwSet.ToProtoBytes).","Upgrade peers and SDKs together to avoid rwset proto drift.","Validate an endorser reply locally before collecting endorsements."],"tags":["fabric","vscc","lscc","rwset","protobuf"],"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"}