{"record":{"id":"a0353dd4ca50fdb6","repo":"micro/go-micro","slug":"errnotfound-a0353d","errorCode":"ErrNotFound","errorMessage":"not found","messagePattern":"not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"model/model.go","lineNumber":11,"sourceCode":"// Package model is an interface for structured data storage with schema awareness.\npackage model\n\nimport (\n\t\"context\"\n\t\"errors\"\n)\n\nvar (\n\t// ErrNotFound is returned when a record doesn't exist.\n\tErrNotFound = errors.New(\"not found\")\n\t// ErrDuplicateKey is returned when a record with the same key already exists.\n\tErrDuplicateKey = errors.New(\"duplicate key\")\n\t// ErrNotRegistered is returned when a table has not been registered.\n\tErrNotRegistered = errors.New(\"table not registered\")\n\t// DefaultModel is the default model.\n\tDefaultModel Model = NewModel()\n)\n\n// Model is a structured data storage interface.\ntype Model interface {\n\t// Init initializes the model.\n\tInit(...Option) error\n\t// Register registers a struct type as a table.\n\tRegister(v interface{}, opts ...RegisterOption) error\n\t// Create inserts a new record. Returns ErrDuplicateKey if key exists.\n\tCreate(ctx context.Context, v interface{}) error\n\t// Read retrieves a record by key into v. Returns ErrNotFound if missing.\n\tRead(ctx context.Context, key string, v interface{}) error","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/model/model.go#L1-L29","documentation":"model.ErrNotFound is the sentinel the model package returns when a queried record does not exist (service rows, registry entries, etc.). Callers should compare with errors.Is(err, model.ErrNotFound) to distinguish 'no such record' from real failures.","triggerScenarios":"Reading a service by name that was never created or was deleted; registry next/Load iterating a table where the requested key is absent; a stale cache referencing a removed service.","commonSituations":"Race between service deregistration and lookup; typos in service names; querying before registration completed; tests asserting on services not seeded in the store.","solutions":["Check errors.Is(err, model.ErrNotFound) and handle it as an expected 'absent' outcome, not a crash.","Verify the record key/name and that the service was registered before lookup.","Retry the lookup with backoff if the record may appear shortly (eventual consistency).","Seed required records in tests before the code under exercise reads them."],"exampleFix":"// before\nsvc, err := reg.GetService(\"foo\")\nif err != nil { return err } // crashes on 'not found'\n// after\nsvc, err := reg.GetService(\"foo\")\nif errors.Is(err, model.ErrNotFound) { return nil // treat as absent\n}\nif err != nil { return err }","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"func isNotFound(err error) bool { return errors.Is(err, model.ErrNotFound) }","tryCatchPattern":"svc, err := reg.GetService(name)\nswitch {\ncase errors.Is(err, model.ErrNotFound):\n    return nil, nil // absent is expected\ncase err != nil:\n    return nil, err\n}","preventionTips":["Always use errors.Is against model.ErrNotFound, never string comparison","Register/seed records before code that reads them","Handle the absent case explicitly in lookup paths","Distinguish stale-cache lookups from genuine typos by logging the queried key"],"tags":["not-found","data-access","sentinel-error"],"backgroundTag":"record-not-found","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}