{"record":{"id":"6061df71764475f2","repo":"hyperledger/fabric","slug":"nil-chaincodeid-in-chaincodeaction-6061df","errorCode":null,"errorMessage":"nil ChaincodeId in ChaincodeAction","messagePattern":"nil ChaincodeId in ChaincodeAction","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/committer/txvalidator/v20/plugindispatcher/dispatcher.go","lineNumber":134,"sourceCode":"\t}\n\n\t/* obtain the list of namespaces we're writing to */\n\trespPayload, err := protoutil.GetActionFromEnvelope(envBytes)\n\tif err != nil {\n\t\treturn peer.TxValidationCode_BAD_RESPONSE_PAYLOAD, errors.WithMessage(err, \"GetActionFromEnvelope failed\")\n\t}\n\ttxRWSet := &rwsetutil.TxRwSet{}\n\tif err = txRWSet.FromProtoBytes(respPayload.Results); err != nil {\n\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","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/committer/txvalidator/v20/plugindispatcher/dispatcher.go#L116-L152","documentation":"Companion check to the header extension: the ChaincodeAction's response payload (RespPayload.ChaincodeId) is nil, so the dispatcher cannot determine the chaincode name/version that produced the results. The transaction is rejected with INVALID_OTHER_REASON because the rwset cannot be attributed to a chaincode for policy validation.","triggerScenarios":"Dispatch validates a transaction where hdrExt.ChaincodeId is present but respPayload.ChaincodeId (from the proposal response payload inside the ChaincodeAction) is nil — typically a tampered, corrupted, or wrongly assembled proposal response payload.","commonSituations":"Malicious transaction crafting; SDK assembling proposal responses incorrectly; corrupted payloads introduced between endorsement and commit.","solutions":["Fix the client SDK so proposal response payloads embed the ChaincodeId correctly","Inspect the offending transaction envelope to find where the payload was dropped/corrupted","Harden the network against tampering (TLS, honest endorsers) and re-submit a fresh transaction","Update to patched Fabric/SDK versions if a serialization bug is responsible"],"exampleFix":"// before: payload built without ChaincodeId\nconst respPayload = new ChaincodeAction({results: rwsetBytes});\n// after\nconst respPayload = new ChaincodeAction({results: rwsetBytes, chaincodeId: {name: 'mycc', version: '1.0'}});","handlingStrategy":"type-guard","validationCode":"// verify endorsement response payload before assembling the transaction\nif (!respPayload.chaincodeId || !respPayload.chaincodeId.name) throw new Error('missing ChaincodeId in ChaincodeAction');","typeGuard":"function hasRespChaincodeId(respPayload) {\n  return !!respPayload && !!respPayload.chaincodeId && !!respPayload.chaincodeId.name && !!respPayload.chaincodeId.version;\n}","tryCatchPattern":"try { await channel.sendTransaction(tx); } catch (e) {\n  if (String(e).includes('nil ChaincodeId in ChaincodeAction')) { /* discard tx, obtain fresh endorsements */ }\n}","preventionTips":["Validate proposal response payloads before assembling transactions","Use TLS and trusted endorsers to prevent payload tampering","Keep SDKs patched against known serialization bugs"],"tags":["hyperledger-fabric","tx-validation","malformed-transaction","chaincode-action"],"backgroundTag":"malformed-transaction","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"}