From 88e408b2790d8a69418a4a441b291aa585175524 Mon Sep 17 00:00:00 2001 From: Deeman Date: Fri, 20 Feb 2026 23:33:39 +0100 Subject: [PATCH] Make dashboard gather resilient to missing analytics tables Use return_exceptions=True so a CatalogException from a single query (e.g. table not yet populated in a fresh env) degrades gracefully instead of crashing the whole dashboard render. Co-Authored-By: Claude Sonnet 4.6 --- web/src/beanflows/dashboard/routes.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/beanflows/dashboard/routes.py b/web/src/beanflows/dashboard/routes.py index c82fca7..c2bea3a 100644 --- a/web/src/beanflows/dashboard/routes.py +++ b/web/src/beanflows/dashboard/routes.py @@ -100,7 +100,7 @@ async def index(): # Fetch all analytics data in parallel (empty lists/None if DB not available) if analytics._conn is not None: - time_series, top_producers, stu_trend, balance, yoy, cot_latest, cot_trend = await asyncio.gather( + results = await asyncio.gather( analytics.get_global_time_series( analytics.COFFEE_COMMODITY_CODE, ["production", "exports", "imports", "ending_stocks", "total_distribution"], @@ -111,7 +111,12 @@ async def index(): analytics.get_production_yoy_by_country(analytics.COFFEE_COMMODITY_CODE, limit=15), analytics.get_cot_positioning_latest(analytics.COFFEE_CFTC_CODE), analytics.get_cot_index_trend(analytics.COFFEE_CFTC_CODE, weeks=104), + return_exceptions=True, ) + time_series, top_producers, stu_trend, balance, yoy, cot_latest, cot_trend = [ + r if not isinstance(r, Exception) else (None if i == 5 else []) + for i, r in enumerate(results) + ] else: time_series, top_producers, stu_trend, balance, yoy = [], [], [], [], [] cot_latest, cot_trend = None, []