micro/go-micro · error · ErrNotFound
not found
Error message
not found
What it means
selector.ErrNotFound is returned by the selector when it cannot find any services matching the requested name in the registry during Select(). Unlike the registry's ErrNotFound ('service not found'), this is the selector-layer 'not found' for the get/next lookup path.
Source
Thrown at selector/selector.go:41
Close() error
// Name of the selector
String() string
}
// Next is a function that returns the next node
// based on the selector's strategy.
type Next func() (*registry.Node, error)
// Filter is used to filter a service during the selection process.
type Filter func([]*registry.Service) []*registry.Service
// Strategy is a selection strategy e.g random, round robin.
type Strategy func([]*registry.Service) Next
var (
DefaultSelector = NewSelector()
ErrNotFound = errors.New("not found")
ErrNoneAvailable = errors.New("none available")
)
View on GitHub (pinned to 24529f1404)
Solutions
- Ensure the target service is running and registered before calling Select
- Retry with backoff on ErrNotFound to ride out startup races
- Verify service names match exactly (including version/namespace labels)
- Refresh or disable the selector cache if staleness is the cause
Example fix
// before
next, err := selector.Select("greeter") // panics/errs when unregistered
// after
next, err := selector.Select("greeter")
if err == selector.ErrNotFound {
time.Sleep(time.Second)
next, err = selector.Select("greeter")
} Defensive patterns
Strategy: retry
Validate before calling
svcs, err := reg.GetService("greeter")
if err != nil || len(svcs) == 0 {
// target not registered; don't attempt Select yet
} Type guard
func isSelectorNotFound(err error) bool {
return errors.Is(err, selector.ErrNotFound)
} Try / catch
next, err := sel.Select("greeter")
if errors.Is(err, selector.ErrNotFound) {
// backoff and retry, or return 'unknown service'
} Prevention
- Confirm the target service is up before client calls
- Add startup backoff/retry around first calls
- Keep selector cache TTLs sane to avoid stale empty views
When it happens
Trigger: Calling selector.Select("service") when the registry returns no services for that name; cached selector whose cache is empty and registry lookup fails; service deregistered between calls.
Common situations: Calling a service that isn't running or registered yet (startup race); name/namespace mismatch between client and server; registry cache staleness after failover; tests using the memory registry without registering the target service.
Related errors
AI-assisted analysis of micro/go-micro@24529f1404 (2026-09-01).
Data as JSON: /api/errors/44ff1ada587c5da3.
Report an issue: GitHub.