From e80e262e255cf1910ea3799f51a08434dd972f6d Mon Sep 17 00:00:00 2001 From: Deeman Date: Thu, 19 Feb 2026 23:10:56 +0100 Subject: [PATCH] Fix NoneType error when user has no subscription g.subscription is explicitly set to None in load_user, so g.get("subscription", {}) returns None (key exists), not {}. Use (g.get(...) or {}) to coalesce None to an empty dict. Co-Authored-By: Claude Opus 4.6 --- web/src/beanflows/dashboard/routes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/src/beanflows/dashboard/routes.py b/web/src/beanflows/dashboard/routes.py index 93ed917..a3e1927 100644 --- a/web/src/beanflows/dashboard/routes.py +++ b/web/src/beanflows/dashboard/routes.py @@ -97,7 +97,7 @@ async def index(): """Coffee analytics dashboard.""" user = g.user stats = await get_user_stats(g.user["id"]) - plan = g.get("subscription", {}).get("plan", "free") + plan = (g.get("subscription") or {}).get("plan", "free") # Fetch all analytics data in parallel (empty lists if DB not available) if analytics._conn is not None: @@ -144,7 +144,7 @@ async def index(): async def countries(): """Country comparison page.""" user = g.user - plan = g.get("subscription", {}).get("plan", "free") + plan = (g.get("subscription") or {}).get("plan", "free") # Get available countries for coffee all_countries = await analytics.get_top_countries(analytics.COFFEE_COMMODITY_CODE, "Production", limit=50)