{"record":{"id":"d5b418bb3854fa27","repo":"hyperledger/fabric","slug":"invalid-chaincode-id-d5b418","errorCode":null,"errorMessage":"invalid chaincode ID","messagePattern":"invalid chaincode ID","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/committer/txvalidator/v20/plugindispatcher/dispatcher.go","lineNumber":143,"sourceCode":"\t\treturn peer.TxValidationCode_BAD_RWSET, errors.WithMessage(err, \"txRWSet.FromProtoBytes failed\")\n\t}\n\n\t// Verify the header extension and response payload contain the ChaincodeId\n\tif hdrExt.ChaincodeId == nil {\n\t\treturn peer.TxValidationCode_INVALID_OTHER_REASON, errors.New(\"nil ChaincodeId in header extension\")\n\t}\n\n\tif respPayload.ChaincodeId == nil {\n\t\treturn peer.TxValidationCode_INVALID_OTHER_REASON, errors.New(\"nil ChaincodeId in ChaincodeAction\")\n\t}\n\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 {","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/committer/txvalidator/v20/plugindispatcher/dispatcher.go#L125-L161","documentation":"Dispatch validates the chaincode action extracted from a transaction's response payload. The header extension's ChaincodeId.Name (ccID) is empty, meaning the transaction proposal header did not carry a chaincode name, so the tx is marked INVALID_CHAINCODE. Fabric throws this as part of the V20 validator's sanity checks before executing validation plugins.","triggerScenarios":"DispatchToPlugin/Dispatch is called during commit-time validation and hdrExt.ChaincodeId.Name is empty — e.g. a malformed ChaincodeHeaderExtension, a tampered or corrupted payload, or a chaincode invocation built without the chaincode ID field in the proposal header.","commonSituations":"Buggy custom client SDK invocations that omit chaincodeId; manually crafted or corrupted envelopes (replayed/attacked txs); mixing peer/SDK versions so header extension fields are not populated; using the default validator to validate transactions produced by incompatible tooling.","solutions":["Fix the client invocation so ChaincodeHeaderExtension.ChaincodeId.Name is always set (pass chaincodeId to the SDK proposal request).","Regenerate the transaction/envelope instead of reusing old serialized ones (replay of stale or hand-crafted payloads).","Verify SDK and peer versions are compatible (header extension proto layout changed across Fabric versions).","Inspect the offending tx with the peer to confirm the proposal header; treat as malicious/corrupt if produced by a third party.","If a custom validation plugin is involved, ensure it does not feed payloads with empty ChaincodeId into Dispatch."],"exampleFix":"// before (client SDK)\nconst request = { fcn: 'invoke', args: ['a','b','1'] };\n// after\nconst request = { chaincodeId: 'mycc', fcn: 'invoke', args: ['a','b','1'] };","handlingStrategy":"validation","validationCode":"if (!request.chaincodeId || request.chaincodeId.length === 0) { throw new Error('chaincodeId must be set on the invocation request'); }","typeGuard":"function hasChaincodeId(req) { return typeof req.chaincodeId === 'string' && req.chaincodeId.length > 0; }","tryCatchPattern":"try { await contract.submitTransaction(...); } catch (err) { if (/invalid chaincode ID/.test(err.message)) { /* fix chaincodeId on request and retry */ } else { throw err; } }","preventionTips":["Always pass chaincodeId in proposal/invocation requests.","Never hand-craft or edit serialized envelopes.","Keep SDK and peer versions aligned.","Log hdrExt contents when debugging validation failures."],"tags":["hyperledger-fabric","validation","chaincode","transaction"],"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"}