{"record":{"id":"f6f82ad740f85d1a","repo":"hyperledger/fabric","slug":"expected-cc-name-s-found-s","errorCode":null,"errorMessage":"expected cc name %s, found %s","messagePattern":"expected cc name (.+?), found (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v12/validation_logic.go","lineNumber":617,"sourceCode":"\t\t\treturn policyErr(fmt.Errorf(\"No read write set for lscc was found\"))\n\t\t}\n\t\t// there must be at least one write\n\t\tif len(lsccrwset.Writes) < 1 {\n\t\t\treturn policyErr(fmt.Errorf(\"LSCC must issue at least one single putState upon deploy/upgrade\"))\n\t\t}\n\t\t// the first key name must be the chaincode id provided in the deployment spec\n\t\tif lsccrwset.Writes[0].Key != cdsArgs.ChaincodeSpec.ChaincodeId.Name {\n\t\t\treturn policyErr(fmt.Errorf(\"expected key %s, found %s\", cdsArgs.ChaincodeSpec.ChaincodeId.Name, lsccrwset.Writes[0].Key))\n\t\t}\n\t\t// the value must be a ChaincodeData struct\n\t\tcdRWSet := &ccprovider.ChaincodeData{}\n\t\terr = proto.Unmarshal(lsccrwset.Writes[0].Value, cdRWSet)\n\t\tif err != nil {\n\t\t\treturn policyErr(fmt.Errorf(\"unmarshalling of ChaincodeData failed, error %s\", err))\n\t\t}\n\t\t// the chaincode name in the lsccwriteset must match the chaincode name in the deployment spec\n\t\tif cdRWSet.Name != cdsArgs.ChaincodeSpec.ChaincodeId.Name {\n\t\t\treturn policyErr(fmt.Errorf(\"expected cc name %s, found %s\", cdsArgs.ChaincodeSpec.ChaincodeId.Name, cdRWSet.Name))\n\t\t}\n\t\t// the chaincode version in the lsccwriteset must match the chaincode version in the deployment spec\n\t\tif cdRWSet.Version != cdsArgs.ChaincodeSpec.ChaincodeId.Version {\n\t\t\treturn policyErr(fmt.Errorf(\"expected cc version %s, found %s\", cdsArgs.ChaincodeSpec.ChaincodeId.Version, cdRWSet.Version))\n\t\t}\n\t\t// it must only write to 2 namespaces: LSCC's and the cc that we are deploying/upgrading\n\t\tfor _, ns := range txRWSet.NsRwSets {\n\t\t\tif ns.NameSpace != \"lscc\" && ns.NameSpace != cdRWSet.Name && len(ns.KvRwSet.Writes) > 0 {\n\t\t\t\treturn policyErr(fmt.Errorf(\"LSCC invocation is attempting to write to namespace %s\", ns.NameSpace))\n\t\t\t}\n\t\t}\n\n\t\tlogger.Debugf(\"Validating %s for cc %s version %s\", lsccFunc, cdRWSet.Name, cdRWSet.Version)\n\n\t\tswitch lsccFunc {\n\t\tcase lscc.DEPLOY:\n\n\t\t\t/******************************************************************/","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L599-L635","documentation":"After unmarshalling, the ChaincodeData.Name embedded in lscc's rwset write must equal the chaincode name in the deployment spec. A mismatch indicates the rwset registers different chaincode data than the spec, so validation fails.","triggerScenarios":"cdRWSet.Name != cdsArgs.ChaincodeSpec.ChaincodeId.Name — lscc wrote ChaincodeData for a different chaincode than the spec claims (tampering, wrong spec, or mixed rwsets).","commonSituations":"Edited proposal payloads; reusing an old instantiate response for a new chaincode; SDK constructing deploy spec from one cc while lscc simulates another.","solutions":["Regenerate the deploy/upgrade transaction so the spec and lscc write refer to the same chaincode.","Never reuse or hand-edit endorsed envelopes.","Confirm the chaincodeId in the SDK request matches the deployed chaincode source.","Validate that lscc is the stock implementation writing correct ChaincodeData."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if cdRWSet.Name != chaincodeSpec.ChaincodeId.Name {\n    return fmt.Errorf(\"ChaincodeData name %q != spec name %q\", cdRWSet.Name, chaincodeSpec.ChaincodeId.Name)\n}","typeGuard":"func chaincodeDataMatchesSpec(cd *ccprovider.ChaincodeData, spec *pb.ChaincodeSpec) bool {\n    return cd != nil && cd.Name == spec.ChaincodeId.Name\n}","tryCatchPattern":"if err := submitTx(envelope); err != nil {\n    if strings.Contains(err.Error(), \"expected cc name \") {\n        // regenerate the deploy/upgrade proposal for the correct chaincode\n    }\n}","preventionTips":["Never reuse endorsed envelopes for a different chaincode","Confirm chaincodeId in the request equals the packaged chaincode","Re-endorse after any change to the deployment spec"],"tags":["hyperledger-fabric","lscc","chaincode-name","transaction-validation"],"backgroundTag":"chaincode-deploy-mismatch","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"}