{"record":{"id":"fc86553b4e8e233f","repo":"hyperledger/fabric","slug":"error-in-handling-register-chaincode-chaincodeid","errorCode":null,"errorMessage":"error in handling register chaincode, chaincodeID name is empty","messagePattern":"error in handling register chaincode, chaincodeID name is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/handler.go","lineNumber":546,"sourceCode":"func (h *Handler) HandleRegister(msg *pb.ChaincodeMessage) {\n\th.stateLock.RLock()\n\tstate := h.state\n\th.stateLock.RUnlock()\n\n\tchaincodeLogger.Debugf(\"Received %s in state %s\", msg.Type, state)\n\tchaincodeID := &pb.ChaincodeID{}\n\terr := proto.Unmarshal(msg.Payload, chaincodeID)\n\tif err != nil {\n\t\tchaincodeLogger.Errorf(\"Error in received %s, could NOT unmarshal registration info: %s\", pb.ChaincodeMessage_REGISTER, err)\n\t\treturn\n\t}\n\n\t// Now register with the chaincodeSupport\n\t// Note: chaincodeID.Name is actually of the form name:version for older chaincodes, and\n\t// of the form label:hash for newer chaincodes.  Either way, it is the handle by which\n\t// we track the chaincode's registration.\n\tif chaincodeID.Name == \"\" {\n\t\th.notifyRegistry(errors.New(\"error in handling register chaincode, chaincodeID name is empty\"))\n\t\treturn\n\t}\n\th.chaincodeID = chaincodeID.Name\n\terr = h.Registry.Register(h)\n\tif err != nil {\n\t\th.notifyRegistry(err)\n\t\treturn\n\t}\n\n\tchaincodeLogger.Debugf(\"Got %s for chaincodeID = %s, sending back %s\", pb.ChaincodeMessage_REGISTER, h.chaincodeID, pb.ChaincodeMessage_REGISTERED)\n\tif err = h.serialSend(&pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTERED}); err != nil {\n\t\tchaincodeLogger.Errorf(\"error sending %s: %s\", pb.ChaincodeMessage_REGISTERED, err)\n\t\th.notifyRegistry(err)\n\t\treturn\n\t}\n\n\th.stateLock.Lock()\n\th.state = Established","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/handler.go#L528-L564","documentation":"HandleRegister in Hyperledger Fabric's chaincode handler registers a chaincode peer-side using the chaincodeID.Name supplied in the ChaincodeMessage REGISTER payload. If the name field is empty there is no handle to track the chaincode by, so the handler notifies the registry of the failure and drops the registration. This indicates a malformed/corrupt registration message from the chaincode side, not a ledger or channel problem.","triggerScenarios":"A chaincode sidecar/container sends a pb.ChaincodeMessage of type REGISTER whose payload's ChaincodeID.Name is an empty string; this can happen with a broken chaincode runtime, a corrupted build, or a custom/legacy chaincode launcher that does not populate the name (which is of the form name:version or label:hash).","commonSituations":"Damaged chaincode images or stale containers after upgrades; custom external builders/launchers that mis-serialize ChaincodeID; intercepted or modified chaincode-to-peer traffic; chaincode packages built with incompatible shim versions.","solutions":["Rebuild and redeploy the chaincode so the shim sends a properly populated ChaincodeID (name:version / label:hash)","Restart the chaincode container (docker restart or reinstall the chaincode) to clear stale state","Verify chaincode shim version compatibility with the peer (lifecycle install path)","Inspect chaincode container logs for shim-side serialization failures before REGISTER"],"exampleFix":"// before (custom launcher sends empty id)\nmsg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTER, Payload: marshal(&pb.ChaincodeID{})}\n// after\nmsg := &pb.ChaincodeMessage{Type: pb.ChaincodeMessage_REGISTER, Payload: marshal(&pb.ChaincodeID{Name: \"mycc:1.0\"})}","handlingStrategy":"validation","validationCode":"if chaincodeID == nil || chaincodeID.Name == \"\" {\n    return fmt.Errorf(\"cannot register chaincode: ChaincodeID.Name is empty\")\n}\n// proceed to send REGISTER with chaincodeID.Name set (e.g. \"mycc:1.0\")","typeGuard":"func validChaincodeID(id *pb.ChaincodeID) bool { return id != nil && strings.TrimSpace(id.Name) != \"\" }","tryCatchPattern":null,"preventionTips":["Always build ChaincodeID with name:version (or label:hash) populated before sending REGISTER","Use the official shim instead of hand-rolled registration code","Watch chaincode container logs for shim startup failures before REGISTER"],"tags":["hyperledger-fabric","chaincode","registration","shim"],"backgroundTag":"chaincode-registration-failed","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"}