{"record":{"id":"166791a3369772ce","repo":"hyperledger/fabric","slug":"existing-version-of-the-cc-on-the-ledger-s-shou","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/v12/validation_logic.go","lineNumber":687,"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":669,"sourceCodeEnd":705,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/handlers/validation/builtin/v12/validation_logic.go#L669-L705","documentation":"VSCC requires that the version in an UPGRADE transaction differs from the version currently recorded on the ledger. If they are equal, the transaction is rejected, because an upgrade must represent an actual version change; otherwise the rwset would overwrite identical state.","triggerScenarios":"Issuing an lscc UPGRADE whose ChaincodeId.Version equals cdLedger.Version for the already-instantiated chaincode.","commonSituations":"Re-running an upgrade command with the same -v flag after a previous successful upgrade; forgetting to bump the version in chaincode.yaml / the deploy command; CI pipelines re-applying a spec without incrementing the version.","solutions":["Increment the chaincode version in the upgrade command (e.g. -v 2.1 instead of 2.0)","Check the current on-ledger version with peer chaincode list -C <channel> and use a different version","Package/install the new version binaries before upgrading so the version actually changes"],"exampleFix":"// before\npeer chaincode upgrade -C mychannel -n mycc -v 1.0   # ledger already at 1.0\n// after\npeer chaincode upgrade -C mychannel -n mycc -v 1.1","handlingStrategy":"validation","validationCode":"const current = await peer.chaincodeList(channelName);\nconst c = current.find(cc => cc.name === targetName);\nif (c && c.version === newVersion) {\n  throw new Error(`Version ${newVersion} already on ledger; increment before upgrade`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await upgradeContract.submitTransaction(...);\n} catch (e) {\n  if (String(e).includes('should be different from the upgraded one')) {\n    // bump version and retry submit\n  }\n}","preventionTips":["Bump the version in every release pipeline automatically (e.g. from git tag)","Compare against peer chaincode list output before submitting","Never reuse a previously committed version string"],"tags":["hyperledger-fabric","chaincode-lifecycle","vscc","version-mismatch"],"backgroundTag":"chaincode-version-unchanged","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"}