{"record":{"id":"37e5c28e7e5952bc","repo":"micro/go-micro","slug":"service-not-found","errorCode":null,"errorMessage":"service not found","messagePattern":"service not found","errorType":"exception","errorClass":"ErrNotFound","httpStatus":null,"severity":"error","filePath":"registry/registry.go","lineNumber":10,"sourceCode":"// Package registry is an interface for service discovery\npackage registry\n\nimport (\n\t\"errors\"\n)\n\nvar (\n\t// Not found error when GetService is called.\n\tErrNotFound = errors.New(\"service not found\")\n\t// Watcher stopped error when watcher is stopped.\n\tErrWatcherStopped = errors.New(\"watcher stopped\")\n)\n\n// The registry provides an interface for service discovery\n// and an abstraction over varying implementations\n// {consul, etcd, zookeeper, ...}.\ntype Registry interface {\n\tInit(...Option) error\n\tOptions() Options\n\tRegister(*Service, ...RegisterOption) error\n\tDeregister(*Service, ...DeregisterOption) error\n\tGetService(string, ...GetOption) ([]*Service, error)\n\tListServices(...ListOption) ([]*Service, error)\n\tWatch(...WatchOption) (Watcher, error)\n\tString() string\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/registry/registry.go#L1-L28","documentation":"registry.ErrNotFound is the sentinel error returned by GetService (and lookups like next/serviceWithName/Load) when no service with the requested name exists in the registry. It is the library's contract for 'unknown service name'.","triggerScenarios":"Calling registry.GetService(\"name\") for a service never registered; calling after the service deregistered or its TTL/lease expired; registry cache missing the entry (e.g. cache not yet populated); tests calling Read/Load for a missing fixture service.","commonSituations":"Typo in the service name or mismatched namespace/environment prefixes; client started before the target service registered (startup race); etcd/consul entries evicted due to TTL expiry or network partition; switching registries between environments.","solutions":["Verify the exact service name matches what the server registered (check name, version, namespace)","Compare with errors.Equal/== against registry.ErrNotFound and implement retry-with-backoff until the service appears","Check the target service is running and successfully registered (inspect registry contents directly)","Increase or verify TTL refresh/heartbeats so registrations don't expire"],"exampleFix":"// before\nsvc, err := registry.GetService(\"grettr\") // typo, err not checked against sentinel\n// after\nif err == registry.ErrNotFound {\n  time.Sleep(500 * time.Millisecond) // backoff and retry\n  svc, err = registry.GetService(\"greeter\")\n}","handlingStrategy":"retry","validationCode":"_, err := reg.GetService(name)\nif err == registry.ErrNotFound {\n  // service absent; wait or check registration before proceeding\n}","typeGuard":"func isNotFound(err error) bool {\n  return errors.Is(err, registry.ErrNotFound)\n}","tryCatchPattern":"svc, err := reg.GetService(\"greeter\")\nif errors.Is(err, registry.ErrNotFound) {\n  // retry with backoff or surface 'unknown service' to caller\n}","preventionTips":["Verify exact service name spelling and namespace at both ends","Use retry with backoff to handle registration startup races","Monitor service TTL renewal so registrations don't expire"],"tags":["registry","service-discovery","not-found"],"backgroundTag":"service-not-found","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}