{"record":{"id":"9ab3d8f09e1e5637","repo":"micro/go-micro","slug":"not-found-9ab3d8","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"exception","errorClass":"ErrNotFound","httpStatus":null,"severity":"warning","filePath":"store/store.go","lineNumber":14,"sourceCode":"// Package store is an interface for distributed data storage.\n// The design document is located at https://github.com/micro/development/blob/master/design/store.md\npackage store\n\nimport (\n\t\"errors\"\n\t\"time\"\n\n\t\"encoding/json\"\n)\n\nvar (\n\t// ErrNotFound is returned when a key doesn't exist.\n\tErrNotFound = errors.New(\"not found\")\n\t// DefaultStore is the file store (persists to ~/micro/store/).\n\tDefaultStore Store = NewStore()\n)\n\n// Store is a data storage interface.\ntype Store interface {\n\t// Init initializes the store. It must perform any required setup on the backing storage implementation and check that it is ready for use, returning any errors.\n\tInit(...Option) error\n\t// Options allows you to view the current options.\n\tOptions() Options\n\t// Read takes a single key name and optional ReadOptions. It returns matching []*Record or an error.\n\tRead(key string, opts ...ReadOption) ([]*Record, error)\n\t// Write() writes a record to the store, and returns an error if the record was not written.\n\tWrite(r *Record, opts ...WriteOption) error\n\t// Delete removes the record with the corresponding key from the store.\n\tDelete(key string, opts ...DeleteOption) error\n\t// List returns any keys that match, or an empty list with no error if none matched.\n\tList(opts ...ListOption) ([]string, error)","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/store/store.go#L1-L32","documentation":"ErrNotFound is the store package's sentinel for a missing key: Get/Read (and the registry helpers built on it) return it when the requested key does not exist in the store. It is a normal, expected outcome for cache-miss style flows, not a crash — the interface contract expects callers to branch on it.","triggerScenarios":"store.Read(\"key\") on a key never written; TestRegistryServiceCheckMissingService path where a service name lookup finds nothing; Load/next iterating a registry/store and exhausting entries.","commonSituations":"Reading before writing (ordering bug), TTL expiry of a previously written record, wrong database/table/namespace configured so the key lives elsewhere, deleted entries from another process.","solutions":["Check errors.Is(err, store.ErrNotFound) and treat it as a cache miss: write the record or return a 404-style response","Verify you are reading from the same database/table/namespace the key was written to","If the key should exist, check TTL options passed at Write time and whether another process deleted it"],"exampleFix":"// before\nrecs, err := s.Read(\"user:42\")\nif err != nil { return err } // 500 on a simple miss\n// after\nrecs, err := s.Read(\"user:42\")\nif err == store.ErrNotFound { return http.StatusNotFound }\nif err != nil { return err }","handlingStrategy":"type-guard","validationCode":"_, err := st.Read(key)\nif err == store.ErrNotFound { /* treat as miss */ }","typeGuard":"func IsNotFound(err error) bool { return err == store.ErrNotFound || errors.Is(err, store.ErrNotFound) }","tryCatchPattern":"recs, err := st.Read(key)\nif IsNotFound(err) { return nil, ErrKeyMissing }\nif err != nil { return nil, err }","preventionTips":["Write before read in init flows; seed expected keys","Set sensible TTLs and handle expiry as a miss","Confirm database/table/namespace options match between writer and reader"],"tags":["store","not-found","cache"],"backgroundTag":"key-not-found","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}