{"record":{"id":"e4abcaa456f6aa3e","repo":"hyperledger/fabric","slug":"invalid-chaincode-version","errorCode":null,"errorMessage":"invalid chaincode version","messagePattern":"invalid chaincode version","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/committer/txvalidator/v14/vscc_validator.go","lineNumber":112,"sourceCode":"\n\t// get name and version of the cc we invoked\n\tccID := hdrExt.ChaincodeId.Name\n\tccVer := respPayload.ChaincodeId.Version\n\n\t// sanity check on ccID\n\tif ccID == \"\" {\n\t\terr = errors.New(\"invalid chaincode ID\")\n\t\tlogger.Errorf(\"%+v\", err)\n\t\treturn peer.TxValidationCode_INVALID_OTHER_REASON, err\n\t}\n\tif ccID != respPayload.ChaincodeId.Name {\n\t\terr = errors.Errorf(\"inconsistent ccid info (%s/%s)\", ccID, respPayload.ChaincodeId.Name)\n\t\tlogger.Errorf(\"%+v\", err)\n\t\treturn peer.TxValidationCode_INVALID_OTHER_REASON, err\n\t}\n\t// sanity check on ccver\n\tif ccVer == \"\" {\n\t\terr = errors.New(\"invalid chaincode version\")\n\t\tlogger.Errorf(\"%+v\", err)\n\t\treturn peer.TxValidationCode_INVALID_OTHER_REASON, err\n\t}\n\n\tvar wrNamespace []string\n\talwaysEnforceOriginalNamespace := v.cr.Capabilities().V1_2Validation()\n\tif alwaysEnforceOriginalNamespace {\n\t\twrNamespace = append(wrNamespace, ccID)\n\t\tif respPayload.Events != nil {\n\t\t\tccEvent := &peer.ChaincodeEvent{}\n\t\t\tif err = proto.Unmarshal(respPayload.Events, ccEvent); err != nil {\n\t\t\t\treturn peer.TxValidationCode_INVALID_OTHER_REASON, errors.Wrapf(err, \"invalid chaincode event\")\n\t\t\t}\n\t\t\tif ccEvent.ChaincodeId != ccID {\n\t\t\t\treturn peer.TxValidationCode_INVALID_OTHER_REASON, errors.Errorf(\"chaincode event chaincode id does not match chaincode action chaincode id\")\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/committer/txvalidator/v14/vscc_validator.go#L94-L130","documentation":"The chaincode version taken from respPayload.ChaincodeId.Version is empty. VSCC requires a version on the action's chaincode ID as a sanity check; an empty version invalidates the transaction with TxValidationCode_INVALID_OTHER_REASON.","triggerScenarios":"The ChaincodeAction's ChaincodeID was serialized without a Version field — e.g. the chaincode was instantiated/deployed without a version, or a custom response builder omitted it.","commonSituations":"Instantiating chaincode with an empty --version flag in older fabric-peer images; SDKs that omit version in the action payload; dev-mode testing where versions were never set.","solutions":["Instantiate/upgrade the chaincode with an explicit non-empty version (e.g. 1.0) on the channel.","Upgrade the peer to a version whose validation populates the action chaincode ID fully.","Regenerate the transaction using the standard SDK flow so version info from the endorsing peer is included."],"exampleFix":"// before\npeer chaincode instantiate -C mychannel -n mycc -v '' ...\n// after\npeer chaincode instantiate -C mychannel -n mycc -v 1.0 -c '{\"Args\":[\"init\"]}'","handlingStrategy":"validation","validationCode":"if action.ChaincodeId.Version == \"\" {\n    return errors.New(\"chaincode version missing in ChaincodeAction; deploy/upgrade with an explicit version\")\n}","typeGuard":"func hasChaincodeVersion(id *peer.ChaincodeID) bool {\n\treturn id != nil && id.Version != \"\"\n}","tryCatchPattern":"if ccVer == \"\" {\n    logger.Warnf(\"tx rejected: invalid chaincode version\")\n    return peer.TxValidationCode_INVALID_OTHER_REASON, nil\n}","preventionTips":["Always pass an explicit -v/--version when instantiating or upgrading chaincode.","Keep chaincode versions semantically incremented per deployment.","Pin peer/shim versions in CI so action payloads are fully populated."],"tags":["fabric","transaction-validation","sanity-check"],"backgroundTag":"invalid-chaincode-id","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"}