agnes-the-ai-analyst/services/session_collector
ZdenekSrotyr e68c2d3f0f fix(session-collector): argv-free run() helper, drop SystemExit footgun (Devin Review on #179)
run_session_collector called collector.main() which did argparse.parse_args()
on uvicorn's sys.argv (['app.main:app', '--host', ...]) → sys.exit(2) →
SystemExit(2), which inherits from BaseException, escapes FastAPI handlers,
and propagates through the thread pool. Every scheduler tick that fired the
endpoint either 500-ed or risked killing the uvicorn worker.

services/session_collector/collector.py now exposes run(dry_run, verbose)
that returns (rc, stats); main() is a thin CLI shim that parses argv and
delegates. The admin endpoint calls run() directly and audit-logs the
per-run stats (users_processed, files_copied, files_skipped) instead of
just the rc. Three regression tests in TestRunHelper.

Closes Devin Review finding on app/api/admin.py:2819 (#179).
2026-05-05 06:31:55 +02:00
..
__init__.py Move standalone services from server/ to services/ 2026-03-09 12:54:30 +01:00
__main__.py Move standalone services from server/ to services/ 2026-03-09 12:54:30 +01:00
collector.py fix(session-collector): argv-free run() helper, drop SystemExit footgun (Devin Review on #179) 2026-05-05 06:31:55 +02:00