{"record":{"id":"2ec4d6ca847bba85","repo":"micro/go-micro","slug":"no-service-name-configured","errorCode":null,"errorMessage":"no service name configured","messagePattern":"no service name configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"health/health.go","lineNumber":356,"sourceCode":"\t}\n}\n\n// RegistryServiceCheck creates a check that verifies the local service\n// registration is visible in the registry. RegistryCheck only proves the\n// registry is reachable; this check also catches the common failure mode\n// where the process is alive and the registry answers, but this service's\n// node lease/record has disappeared and other services can no longer\n// discover it.\n//\n// Pass the service name and node ID used during registration. The default\n// RPC server node ID is service.Options().Name + \"-\" + service.Options().Id.\nfunc RegistryServiceCheck(reg registry.Registry, serviceName, nodeID string) CheckFunc {\n\treturn func(ctx context.Context) error {\n\t\tif reg == nil {\n\t\t\treturn errors.New(\"no registry configured\")\n\t\t}\n\t\tif serviceName == \"\" {\n\t\t\treturn errors.New(\"no service name configured\")\n\t\t}\n\t\tif nodeID == \"\" {\n\t\t\treturn errors.New(\"no service node configured\")\n\t\t}\n\n\t\terrc := make(chan error, 1)\n\t\tgo func() {\n\t\t\tservices, err := reg.GetService(serviceName, registry.GetContext(ctx))\n\t\t\tif err != nil {\n\t\t\t\terrc <- fmt.Errorf(\"registry %s lookup %s failed: %w\", reg.String(), serviceName, err)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tfor _, service := range services {\n\t\t\t\tfor _, node := range service.Nodes {\n\t\t\t\t\tif node.Id == nodeID {\n\t\t\t\t\t\terrc <- nil\n\t\t\t\t\t\treturn\n\t\t\t\t\t}","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/health/health.go#L338-L374","documentation":"RegistryServiceCheck requires a non-empty serviceName because it queries the registry with GetService(serviceName). An empty name cannot identify a service, so the check returns this error immediately before touching the registry.","triggerScenarios":"Calling health.RegistryServiceCheck(reg, \"\", nodeID) with an empty serviceName argument, then executing the check.","commonSituations":"Service name read from an unset config key or empty environment variable; call sites that pass options.Name before options are fully initialized; refactors that changed how the name is derived.","solutions":["Pass the correct service name — typically service.Options().Name — to RegistryServiceCheck.","Validate the config value feeding serviceName at startup and fail fast if empty.","Default to the process's known service name instead of an empty string."],"exampleFix":"// before\ncheck := health.RegistryServiceCheck(reg, cfg.ServiceName, nodeID) // cfg.ServiceName == \"\"\n\n// after\nname := cfg.ServiceName\nif name == \"\" {\n\tname = svc.Options().Name\n}\ncheck := health.RegistryServiceCheck(reg, name, nodeID)","handlingStrategy":"validation","validationCode":"if serviceName == \"\" {\n\tserviceName = svc.Options().Name\n}\ncheck := health.RegistryServiceCheck(reg, serviceName, nodeID)","typeGuard":null,"tryCatchPattern":"if err := check(ctx); err != nil {\n\tif err.Error() == \"no service name configured\" {\n\t\tlog.Error(\"health check misconfigured: serviceName is empty\")\n\t}\n}","preventionTips":["Read serviceName from service.Options().Name, never from raw config that may be unset.","Fail fast at boot when required identity config keys are empty.","Unit-test health wiring with realistic populated options."],"tags":["health","registry","validation","configuration"],"backgroundTag":"missing-required-argument","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}