{"record":{"id":"516b10d600ba8f56","repo":"hyperledger/fabric","slug":"nil-chaincodeid-in-chaincodeaction","errorCode":null,"errorMessage":"nil ChaincodeId in ChaincodeAction","messagePattern":"nil ChaincodeId in ChaincodeAction","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/committer/txvalidator/v14/vscc_validator.go","lineNumber":92,"sourceCode":"\t   3) does it write to any cc that cannot be invoked? */\n\twritesToLSCC := false\n\twritesToNonInvokableSCC := false\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_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","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/committer/txvalidator/v14/vscc_validator.go#L74-L110","documentation":"VSCCValidateTx found respPayload.ChaincodeId nil: the ChaincodeAction inside the transaction's response payload lacks a ChaincodeID. VSCC uses it to cross-check the invoked chaincode's version and name against the header extension, so the transaction is marked invalid with TxValidationCode_INVALID_OTHER_REASON.","triggerScenarios":"A chaincode (or the peer executing it) produced a ChaincodeAction whose Response.Payload (ChaincodeAction) has no chaincode_id set — e.g. chaincode results forged or rebuilt by a client, or responses injected/altered after endorsement.","commonSituations":"Hand-crafted proposal responses submitted directly to orderers; custom chaincode shim versions producing incomplete actions; tampering with endorsement payloads before collection.","solutions":["Ensure the chaincode runs on a matching Fabric shim/peer version so the peer populates ChaincodeAction.ChaincodeId correctly.","Do not construct or modify proposal responses manually; collect endorsements via the SDK's transaction assembly.","Verify chaincode deployment/invocation flow uses the standard proposal-response path instead of custom payload generation."],"exampleFix":"// before: client assembles result payload manually\naction := &peer.ChaincodeAction{Results: rwsetBytes}\n// after: use SDK to assemble from real endorsement responses\ntx, _ := transaction.New(proposalResponse)\n// peer sets action.ChaincodeId itself","handlingStrategy":"validation","validationCode":"action := &peer.ChaincodeAction{}\nif err := proto.Unmarshal(respPayload.Results, action); err != nil || action.ChaincodeId == nil {\n    return errors.New(\"ChaincodeAction must contain a ChaincodeId; use standard endorsement flow\")\n}","typeGuard":"func hasActionChaincodeId(resp *peer.ChaincodeAction) bool {\n\treturn resp != nil && resp.ChaincodeId != nil\n}","tryCatchPattern":"if respPayload.ChaincodeId == nil {\n    logger.Warnf(\"tx rejected: nil ChaincodeId in ChaincodeAction\")\n    return peer.TxValidationCode_INVALID_OTHER_REASON, nil\n}","preventionTips":["Collect proposal responses through the SDK; never hand-build ChaincodeAction payloads.","Do not modify endorsement responses between collection and envelope creation.","Run chaincode on a shim version compatible with the peer."],"tags":["fabric","transaction-validation","missing-chaincode-id"],"backgroundTag":"invalid-transaction-header","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"}