{"record":{"id":"49229c48d8973112","repo":"hyperledger/fabric","slug":"expected-cc-name-s-found-s-49229c","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/v13/lscc_validation_logic.go","lineNumber":475,"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":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v13/lscc_validation_logic.go#L457-L493","documentation":"After successfully unmarshalling ChaincodeData from the lscc write-set, the validator checks that its Name matches the chaincode name in the submitted ChaincodeDeploymentSpec. A mismatch means the lscc rwset records a different chaincode than the one the transaction claims to deploy/upgrade, so the transaction is rejected as a policy violation.","triggerScenarios":"A deploy/upgrade transaction for chaincode A whose lscc write-set value contains ChaincodeData with Name B — typically from a hand-modified proposal, replayed transaction, or tampered rwset.","commonSituations":"Reusing a serialized ChaincodeData blob from a previous deployment of a different chaincode, custom lifecycle scripts mixing up name fields, replaying an old proposal after renaming the chaincode, malicious transaction tampering.","solutions":["Rebuild the deploy/upgrade proposal with the SDK/lifecycle tooling so ChaincodeData.Name is generated from ChaincodeSpec.ChaincodeId.Name.","If using custom tooling, ensure the ChaincodeData written by lscc uses exactly the ChaincodeId.Name from the proposal.","Do not reuse cached/pre-serialized ChaincodeData across different chaincode deployments.","Confirm you are not replaying a proposal captured for another chaincode or channel."],"exampleFix":"// before: stale data blob from another cc\ncd.Name = \"oldcc\"\n// after: derive from the deployment spec\ncd := &ccprovider.ChaincodeData{Name: cds.ChaincodeSpec.ChaincodeId.Name, Version: cds.ChaincodeSpec.ChaincodeId.Version, ...}","handlingStrategy":"validation","validationCode":"// before submit: ensure lscc ChaincodeData name matches the spec\ncd := &ccprovider.ChaincodeData{}\nproto.Unmarshal(lsccWriteValue, cd)\nif cd.Name != cds.ChaincodeSpec.ChaincodeId.Name {\n    return fmt.Errorf(\"proposal name %s != lscc record name %s\", cds.ChaincodeSpec.ChaincodeId.Name, cd.Name)\n}","typeGuard":"func nameMatches(cd *ccprovider.ChaincodeData, specName string) bool { return cd != nil && cd.Name == specName }","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"expected cc name\") { /* regenerate the deploy/upgrade proposal with correct name */ }","preventionTips":["Derive ChaincodeData fields from the same ChaincodeSpec used in the proposal","Do not reuse serialized ChaincodeData across chaincodes","Label and store signed proposals by chaincode name to avoid replay mix-ups"],"tags":["hyperledger-fabric","lscc","chaincode-lifecycle","transaction-validation"],"backgroundTag":"chaincode-name-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"}