From 2ce7e2b6d022e0acd90946daacb9ffde45935f8f Mon Sep 17 00:00:00 2001 From: Robin Lindbladh Date: Tue, 24 Mar 2026 21:11:49 +0100 Subject: [PATCH] fix: broaden _log_portfolio exception catch to handle all failures OSError only covers file I/O errors; json.dump can also raise TypeError on non-serializable data. Use Exception to ensure logging failures never discard analysis results. Co-Authored-By: Claude Opus 4.6 (1M context) --- tradingagents/graph/portfolio_analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tradingagents/graph/portfolio_analysis.py b/tradingagents/graph/portfolio_analysis.py index 6cf3f709..0c4bc296 100644 --- a/tradingagents/graph/portfolio_analysis.py +++ b/tradingagents/graph/portfolio_analysis.py @@ -63,7 +63,7 @@ class PortfolioAnalyzer: try: self._log_portfolio(trade_date, tickers, individual_results, portfolio_summary) - except OSError as e: + except Exception as e: if debug: print(f"Warning: failed to save portfolio log: {e}")