{"record":{"id":"c7bde9c703d3c70b","repo":"hyperledger/fabric","slug":"invalid-chaincode-version-c7bde9","errorCode":null,"errorMessage":"invalid chaincode version","messagePattern":"invalid chaincode version","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/committer/txvalidator/v20/plugindispatcher/dispatcher.go","lineNumber":154,"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_CHAINCODE, 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_CHAINCODE, 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_CHAINCODE, err\n\t}\n\n\twrNamespace := map[string]bool{}\n\twrNamespace[ccID] = true\n\tif respPayload.Events != nil {\n\t\tccEvent := &peer.ChaincodeEvent{}\n\t\tif err = proto.Unmarshal(respPayload.Events, ccEvent); err != nil {\n\t\t\treturn peer.TxValidationCode_INVALID_OTHER_REASON, errors.Wrapf(err, \"invalid chaincode event\")\n\t\t}\n\t\tif ccEvent.ChaincodeId != ccID {\n\t\t\treturn peer.TxValidationCode_INVALID_OTHER_REASON, errors.Errorf(\"chaincode event chaincode id does not match chaincode action chaincode id\")\n\t\t}\n\t}\n\n\tnamespaces := make(map[string]struct{})\n\tfor _, ns := range txRWSet.NsRwSets {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/committer/txvalidator/v20/plugindispatcher/dispatcher.go#L136-L172","documentation":"The chaincode version taken from the chaincode action's response payload (respPayload.ChaincodeId.Version) is empty during Dispatch validation. The V20 validator requires both name and version to compute write namespaces and select chaincode metadata, so an empty version invalidates the tx.","triggerScenarios":"Dispatch is called and respPayload.ChaincodeId.Version == \"\" — typically a response payload constructed without the version field (custom/malformed endorser or client), or an old/incompatible serialization path.","commonSituations":"Hand-crafted or tool-generated endorsements missing ChaincodeId.Version; custom chaincode shim or modified fabric-samples code that clears the field; version skew between endorser and validator code.","solutions":["Regenerate the transaction with a standard peer/SDK so ChaincodeId.Version is populated from the deployed chaincode definition.","Ensure the chaincode is properly instantiated/upgraded with a real version string (e.g. '1.0'), not empty.","Align fabric-peer and fabric-sdk/shim versions.","Audit custom endorsement paths for stripped Version fields."],"exampleFix":"// before (chaincode deployment)\nchaincode install -n mycc -v \"\"   // invalid\n// after\npeer chaincode install -n mycc -v 1.0","handlingStrategy":"validation","validationCode":"if (!respPayload.chaincodeId.version) { throw new Error('chaincode version missing in response payload'); }","typeGuard":"function hasChaincodeVersion(p) { return typeof p?.chaincodeId?.version === 'string' && p.chaincodeId.version.length > 0; }","tryCatchPattern":"try { await contract.submitTransaction(...); } catch (err) { if (/invalid chaincode version/.test(err.message)) { /* redeploy with a real version and resubmit */ } else { throw err; } }","preventionTips":["Deploy chaincode with a non-empty version string.","Use standard peer/SDK serialization paths.","Keep endorser and validator code versions in sync.","Do not strip fields when re-serializing payloads."],"tags":["hyperledger-fabric","validation","chaincode-version"],"backgroundTag":"invalid-chaincode-version","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}