{"record":{"id":"44ff1ada587c5da3","repo":"micro/go-micro","slug":"not-found","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"exception","errorClass":"ErrNotFound","httpStatus":null,"severity":"error","filePath":"selector/selector.go","lineNumber":41,"sourceCode":"\tClose() error\n\t// Name of the selector\n\tString() string\n}\n\n// Next is a function that returns the next node\n// based on the selector's strategy.\ntype Next func() (*registry.Node, error)\n\n// Filter is used to filter a service during the selection process.\ntype Filter func([]*registry.Service) []*registry.Service\n\n// Strategy is a selection strategy e.g random, round robin.\ntype Strategy func([]*registry.Service) Next\n\nvar (\n\tDefaultSelector = NewSelector()\n\n\tErrNotFound      = errors.New(\"not found\")\n\tErrNoneAvailable = errors.New(\"none available\")\n)\n","sourceCodeStart":23,"sourceCodeEnd":44,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/selector/selector.go#L23-L44","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nnext, err := selector.Select(\"greeter\") // panics/errs when unregistered\n// after\nnext, err := selector.Select(\"greeter\")\nif err == selector.ErrNotFound {\n  time.Sleep(time.Second)\n  next, err = selector.Select(\"greeter\")\n}","handlingStrategy":"retry","validationCode":"svcs, err := reg.GetService(\"greeter\")\nif err != nil || len(svcs) == 0 {\n  // target not registered; don't attempt Select yet\n}","typeGuard":"func isSelectorNotFound(err error) bool {\n  return errors.Is(err, selector.ErrNotFound)\n}","tryCatchPattern":"next, err := sel.Select(\"greeter\")\nif errors.Is(err, selector.ErrNotFound) {\n  // backoff and retry, or return 'unknown service'\n}","preventionTips":["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"],"tags":["selector","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"}