{"record":{"id":"a66ac064d3cfbafc","repo":"hyperledger/fabric","slug":"getchaincodeaction-error-s","errorCode":null,"errorMessage":"GetChaincodeAction error %s","messagePattern":"GetChaincodeAction error (.+?)","errorType":"validation","errorClass":"VSCCEndorsementPolicyError","httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":571,"sourceCode":"\n\t\t// validate chaincode version\n\t\tccVersion := cdsArgs.ChaincodeSpec.ChaincodeId.Version\n\t\t// it must comply with the lscc.ChaincodeVersionRegExp\n\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)","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L553-L589","documentation":"VSCC unmarshals pRespPayload.Extension into a ChaincodeAction proto. Failure here means the extension bytes are not a valid ChaincodeAction, so the lscc transaction fails validation with this wrapped policy error.","triggerScenarios":"An lscc transaction whose ProposalResponsePayload.Extension bytes are corrupt, truncated, or produced by a different protobuf message type than ChaincodeAction.","commonSituations":"Mismatched proto definitions between client SDK and peer, custom endorsement code putting the wrong message in the extension, or byte-level corruption/tampering of the transaction.","solutions":["Ensure the extension is the raw protobuf bytes of the ChaincodeAction returned by the endorser (no re-encoding).","Regenerate the transaction with a matching Fabric SDK version and resubmit.","Diff the proto definitions used by client and peer if a custom build is in play."],"exampleFix":"// before: wrapping the action in another envelope\next, _ := protoutil.Marshal(&pb.ProposalResponse{Payload: actionBytes})\n// after: store the ChaincodeAction bytes directly\next := actionBytes // protoutil.Marshal(chaincodeAction)","handlingStrategy":"validation","validationCode":"var ca pb.ChaincodeAction\nif proto.Unmarshal(prp.Extension, &ca) != nil {\n    return errors.New(\"extension is not a valid ChaincodeAction\")\n}","typeGuard":"func isChaincodeAction(b []byte) bool {\n    var ca pb.ChaincodeAction\n    return len(b) > 0 && proto.Unmarshal(b, &ca) == nil\n}","tryCatchPattern":"if _, err := protoutil.UnmarshalChaincodeAction(prp.Extension); err != nil {\n    logger.Warnf(\"invalid ChaincodeAction in extension: %v\", err)\n    return policyErr(err)\n}","preventionTips":["Store the raw marshaled ChaincodeAction as the extension.","Keep client and peer proto definitions in lockstep.","Unit-test payload assembly with a local unmarshal round-trip."],"tags":["fabric","vscc","lscc","protobuf","validation"],"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"}