{"record":{"id":"da43c02344e2a19d","repo":"micro/go-micro","slug":"no-registry-configured","errorCode":null,"errorMessage":"no registry configured","messagePattern":"no registry configured","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"health/health.go","lineNumber":322,"sourceCode":"\t}\n}\n\n// RegistryCheck creates a check that verifies the service registry is\n// reachable by listing services. Registered checks are critical by\n// default, so a service is reported not-ready when it loses its\n// connection to the registry — wire it to a Kubernetes readiness probe\n// on /health/ready:\n//\n//\thealth.Register(\"registry\", health.RegistryCheck(service.Options().Registry))\n//\n// The lookup runs under the check's timeout, so an unreachable registry\n// (for example an etcd that has gone away) is reported as down rather\n// than blocking the probe. Registries that honor ListContext also receive\n// the check context directly.\nfunc RegistryCheck(reg registry.Registry) 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\terrc := make(chan error, 1)\n\t\tgo func() {\n\t\t\t_, err := reg.ListServices(registry.ListContext(ctx))\n\t\t\terrc <- err\n\t\t}()\n\t\tselect {\n\t\tcase err := <-errc:\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"registry %s unreachable: %w\", reg.String(), err)\n\t\t\t}\n\t\t\treturn nil\n\t\tcase <-ctx.Done():\n\t\t\treturn fmt.Errorf(\"registry %s check timed out: %w\", reg.String(), ctx.Err())\n\t\t}\n\t}\n}\n","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/health/health.go#L304-L340","documentation":"RegistryCheck returns a CheckFunc used by the health framework to probe a service registry. If the Registry argument is nil, the check immediately fails with this error so the health report shows the registry as down instead of panicking on a nil-pointer call to ListServices.","triggerScenarios":"Passing nil as the registry.Registry to health.RegistryCheck, then running the resulting check during a health probe.","commonSituations":"Optional registry dependencies (e.g. etcd) not configured in the environment; wiring code that always calls RegistryCheck even when no registry plugin is enabled; misconfigured service options leaving the registry unset.","solutions":["Configure a real registry (etcd, consul, memory) so the service passes a non-nil registry.Registry to RegistryCheck.","Only register the registry health check when a registry is actually configured.","If nil is expected, map this error to a benign/down state in your health aggregation instead of treating it as a crash."],"exampleFix":"// before\nchecks[\"registry\"] = health.RegistryCheck(nil)\n\n// after\nif reg != nil {\n\tchecks[\"registry\"] = health.RegistryCheck(reg)\n}","handlingStrategy":"validation","validationCode":"if reg == nil {\n\t// skip registering the health check or configure a registry first\n}","typeGuard":"func hasRegistry(reg registry.Registry) bool {\n\treturn reg != nil\n}","tryCatchPattern":"if err := check(ctx); err != nil {\n\tif err.Error() == \"no registry configured\" {\n\t\treport.Status = \"down\"\n\t\treport.Detail = \"registry backend not configured\"\n\t}\n}","preventionTips":["Guard health-check wiring with a nil-registry check.","Make registry configuration explicit at startup and fail fast if required.","Document that etcd/consul backends are optional so operators know the health check will report down without one."],"tags":["health","registry","nil-check","configuration"],"backgroundTag":"no-registries-configured","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}