{"record":{"id":"a53140e2b7abd5f0","repo":"JuliusBrussee/caveman","slug":"list-memories-w","errorCode":null,"errorMessage":"list memories: %w","messagePattern":"list memories: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mem/store.go","lineNumber":602,"sourceCode":"\t\t\thi = mid - 1\n\t\t}\n\t}\n\tfor lo > 0 && lo < len(b) && !utf8.RuneStart(b[lo]) {\n\t\tlo--\n\t}\n\treturn b[:lo]\n}\n\n// Recover returns the byte-exact original for a recall hit's recovery handle.\nfunc (s *Store) Recover(handle string) ([]byte, error) {\n\treturn s.eng.Retrieve(handle)\n}\n\n// all loads every memory.\nfunc (s *Store) all() ([]Memory, error) {\n\trows, err := s.db.Query(memorySelect + ` WHERE valid_until IS NULL`)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"list memories: %w\", err)\n\t}\n\tdefer rows.Close()\n\tvar out []Memory\n\tfor rows.Next() {\n\t\tvar m Memory\n\t\tif err := scanMemory(rows, &m); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tout = append(out, m)\n\t}\n\treturn out, rows.Err()\n}\n\nconst memorySelect = `SELECT id, text, created_at, valid_from, valid_until, supersedes, superseded_by FROM memories`\n\ntype rowScanner interface {\n\tScan(dest ...any) error\n}","sourceCodeStart":584,"sourceCodeEnd":620,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/mem/store.go#L584-L620","documentation":"Store.all is the internal loader behind Recall; it runs `SELECT ... FROM memories WHERE valid_until IS NULL` and wraps any Query error as \"list memories\". Recall surfaces this directly (no further wrapping). It means the durable-memory listing query itself failed, before any rows were scanned.","triggerScenarios":"Store.Recall calls s.all() and the SELECT fails: DB closed, corrupted, locked, disk I/O error, or the memories table missing/unmigrated.","commonSituations":"Recalling after Store.Close, an unreadable/corrupt SQLite file, or a failed schema migration; cmdRecall users see this when the cavemem home database cannot be opened by another process holding an exclusive lock.","solutions":["Check the underlying SQLite error for cause (locked, corrupted, no such table).","Ensure the Store is open and migrations ran before calling Recall.","Release competing DB locks / close other processes using the same database file.","If corrupted, restore from backup or reinitialize the store."],"exampleFix":"// before\nhits, err := store.Recall(ctx, q, opts) // err: list memories: ...\n// after\nif err != nil {\n    log.Printf(\"recall failed listing memories: %v\", err)\n    return fallbackResults()\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"hits, err := store.Recall(ctx, q, opts)\nif err != nil {\n    // 'list memories: ...' — check wrapped SQLite cause; retry once after\n    // confirming store is open and no lock contention\n}","preventionTips":["Ensure migrations ran at store open before any Recall.","Avoid multiple processes holding the same cavemem database concurrently.","Back up the SQLite file; corruption here fails every Recall."],"tags":["database","sqlite","wrapped-error"],"backgroundTag":"database-query-failed","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}