{"record":{"id":"3fb9db4ed7ffa842","repo":"hyperledger/fabric","slug":"existing-version-of-the-cc-on-the-ledger-s-shou-3fb9db","errorCode":null,"errorMessage":"Existing version of the cc on the ledger (%s) should be different from the upgraded one","messagePattern":"Existing version of the cc on the ledger \\((.+?)\\) should be different from the upgraded one","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/handlers/validation/builtin/v13/lscc_validation_logic.go","lineNumber":545,"sourceCode":"\t\t\t// CONS: this would be a point of non-determinism\n\t\t\terr := vscc.checkInstantiationPolicy(chid, env, pol, payl)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\tcase lscc.UPGRADE:\n\t\t\t/**************************************************************/\n\t\t\t/* security check 1 - cc in the LCCC table of instantiated cc */\n\t\t\t/**************************************************************/\n\t\t\tif !ccExistsOnLedger {\n\t\t\t\treturn policyErr(fmt.Errorf(\"Upgrading non-existent chaincode %s\", cdsArgs.ChaincodeSpec.ChaincodeId.Name))\n\t\t\t}\n\n\t\t\t/**********************************************************/\n\t\t\t/* security check 2 - existing cc's version was different */\n\t\t\t/**********************************************************/\n\t\t\tif cdLedger.Version == cdsArgs.ChaincodeSpec.ChaincodeId.Version {\n\t\t\t\treturn policyErr(fmt.Errorf(\"Existing version of the cc on the ledger (%s) should be different from the upgraded one\", cdsArgs.ChaincodeSpec.ChaincodeId.Version))\n\t\t\t}\n\n\t\t\t/****************************************************************************/\n\t\t\t/* security check 3 validation of rwset (and of collections if enabled) */\n\t\t\t/****************************************************************************/\n\t\t\t// Only in v1.2, a collection can be updated during a chaincode upgrade\n\t\t\tif ac.V1_2Validation() {\n\t\t\t\t// do extra validation for collections\n\t\t\t\terr := vscc.validateRWSetAndCollection(lsccrwset, cdRWSet, lsccArgs, lsccFunc, ac, chid)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// there can only be a single ledger write\n\t\t\t\tif len(lsccrwset.Writes) != 1 {\n\t\t\t\t\treturn policyErr(fmt.Errorf(\"LSCC can only issue a single putState upon upgrade\"))\n\t\t\t\t}\n\t\t\t}","sourceCodeStart":527,"sourceCodeEnd":563,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v13/lscc_validation_logic.go#L527-L563","documentation":"On upgrade, the version recorded on the ledger must differ from the version in the upgrade proposal. Fabric requires an actual version change (e.g. 1.0 -> 1.1); re-submitting an upgrade with the same version as the currently instantiated chaincode is rejected to make upgrades meaningful and idempotency-detectable.","triggerScenarios":"An lscc upgrade transaction whose ChaincodeSpec.ChaincodeId.Version equals cdLedger.Version — re-running the same upgrade, or a script that forgets to bump the version.","commonSituations":"Replayed upgrade proposals after a successful upgrade, CI scripts with hard-coded versions, developers forgetting to bump the version in the deployment spec after code changes, attempting to 're-upgrade' to force re-initialization without a version bump.","solutions":["Bump the chaincode version in the upgrade proposal (e.g. from 1.0 to 1.1) and rebuild/reinstall the package.","Query the currently instantiated version first and submit the upgrade with a strictly different version.","Stop re-submitting an already-committed upgrade transaction; check the txid status instead.","Parameterize version in deployment scripts instead of hard-coding it."],"exampleFix":"// before\nversion = \"1.0\" // same as ledger\n// after\nversion = \"1.1\" // must differ from the instantiated version","handlingStrategy":"validation","validationCode":"// ensure the new version differs from the ledger version\nledgerCd := lsccClient.Query(\"getccdata\", []string{\"mycc\"})\nif cds.ChaincodeSpec.ChaincodeId.Version == ledgerCd.Version {\n    return errors.New(\"upgrade version must differ from \" + ledgerCd.Version)\n}","typeGuard":"func isUpgradeVersion(current, proposed string) bool { return proposed != \"\" && proposed != current }","tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"should be different from the upgraded one\") { /* bump the version and resubmit the upgrade */ }","preventionTips":["Always increment the version when upgrading","Read the current version from lscc before building the proposal","Avoid replaying committed upgrade transactions; check txid status"],"tags":["hyperledger-fabric","lscc","upgrade","version-mismatch"],"backgroundTag":"chaincode-version-not-changed","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"}