personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(errors): surface masked failures in telemetry/dedup/log-read paths

- warn on JSONL sidecar failures in think/talents.py and think/dream.py
- surface finish-log scan, facet metadata, dedup, and settings/sol log read failures
- keep exception narrowing scoped to the audited sites only

+41 -23
+3 -2
apps/import/routes.py
··· 4 4 from __future__ import annotations 5 5 6 6 import json 7 + import logging 7 8 import re 8 9 import time 9 10 from pathlib import Path ··· 290 291 "entry_count": existing.get("entry_count", 0), 291 292 "import_id": existing.get("import_id", ""), 292 293 } 293 - except Exception: 294 - pass # dedup check is best-effort 294 + except OSError as exc: 295 + logging.warning("Dedup check failed for %s: %s", file_path, exc) 295 296 296 297 result: dict[str, Any] = { 297 298 "path": str(file_path),
+2 -2
apps/settings/routes.py
··· 1671 1671 line = line.strip() 1672 1672 if line: 1673 1673 entries.append(json.loads(line)) 1674 - except Exception: 1675 - pass 1674 + except (OSError, json.JSONDecodeError) as exc: 1675 + logger.warning("Failed to read settings log %s: %s", target_file, exc) 1676 1676 1677 1677 # Reverse to show newest first within the day 1678 1678 entries.reverse()
+3 -2
apps/sol/routes.py
··· 6 6 from __future__ import annotations 7 7 8 8 import json 9 + import logging 9 10 import re 10 11 from datetime import date, datetime 11 12 from functools import lru_cache ··· 290 291 use_info = _parse_use_file(use_file) 291 292 if use_info: 292 293 uses.append(use_info) 293 - except IOError: 294 - pass 294 + except OSError as exc: 295 + logging.warning("Failed to read use day index %s: %s", day_index_path, exc) 295 296 296 297 # Also check for running uses (only have _active files, no day index entry yet) 297 298 for use_file in talents_dir.glob("*/*_active.jsonl"):
+12 -3
think/cortex.py
··· 603 603 event = json.loads(line) 604 604 if event.get("event") in ["finish", "error"]: 605 605 return True 606 - except json.JSONDecodeError: 606 + except json.JSONDecodeError as exc: 607 + self.logger.warning( 608 + "Malformed event in %s while scanning for finish: %s", 609 + file_path, 610 + exc, 611 + ) 607 612 continue 608 - except Exception: 609 - pass 613 + except FileNotFoundError: 614 + self.logger.debug("Use log disappeared before finish scan: %s", file_path) 615 + except OSError as exc: 616 + self.logger.warning( 617 + "Failed to scan %s for finish events: %s", file_path, exc 618 + ) 610 619 return False 611 620 612 621 def _complete_use_file(self, use_id: str, file_path: Path) -> None:
+10 -6
think/dream.py
··· 69 69 try: 70 70 Path(path).parent.mkdir(parents=True, exist_ok=True) 71 71 self.file = open(path, "a", encoding="utf-8") 72 - except Exception: 73 - pass 72 + except OSError as exc: 73 + logging.warning("Failed to open dream JSONL sidecar %s: %s", path, exc) 74 74 75 75 def log(self, event: str, **fields) -> None: 76 76 if not self.file: ··· 81 81 try: 82 82 self.file.write(json.dumps(data, ensure_ascii=False) + "\n") 83 83 self.file.flush() 84 - except Exception: 85 - pass 84 + except OSError as exc: 85 + logging.warning( 86 + "Failed to write dream JSONL sidecar %s: %s", self.file.name, exc 87 + ) 86 88 87 89 def close(self) -> None: 88 90 if self.file: 89 91 try: 90 92 self.file.close() 91 - except Exception: 92 - pass 93 + except OSError as exc: 94 + logging.warning( 95 + "Failed to close dream JSONL sidecar %s: %s", self.file.name, exc 96 + ) 93 97 94 98 95 99 _jsonl: DreamJSONLWriter | None = None
+5 -2
think/facets.py
··· 243 243 } 244 244 245 245 facets[facet_name] = facet_info 246 - except Exception as exc: # pragma: no cover - metadata optional 247 - logging.debug("Error reading %s: %s", facet_json, exc) 246 + except ( 247 + OSError, 248 + json.JSONDecodeError, 249 + ) as exc: # pragma: no cover - metadata optional 250 + logging.warning("Failed to read facet metadata %s: %s", facet_json, exc) 248 251 249 252 return facets 250 253
+6 -6
think/talents.py
··· 75 75 try: 76 76 Path(path).parent.mkdir(parents=True, exist_ok=True) 77 77 self.file = open(path, "a", encoding="utf-8") 78 - except Exception: 79 - pass # Fail silently if can't open file 78 + except OSError as exc: 79 + LOG.warning("Failed to open JSON event sidecar %s: %s", path, exc) 80 80 81 81 def emit(self, data: Event) -> None: 82 82 line = json.dumps(data, ensure_ascii=False) ··· 86 86 try: 87 87 self.file.write(line + "\n") 88 88 self.file.flush() 89 - except Exception: 90 - pass # Fail silently on write errors 89 + except OSError as exc: 90 + LOG.warning("Failed to write JSON event sidecar %s: %s", self.path, exc) 91 91 92 92 def close(self) -> None: 93 93 if self.file: 94 94 try: 95 95 self.file.close() 96 - except Exception: 97 - pass 96 + except OSError as exc: 97 + LOG.warning("Failed to close JSON event sidecar %s: %s", self.path, exc) 98 98 99 99 100 100 # =============================================================================