From f25d7a974571fa7c40a2c627b5e0e576cf19f738 Mon Sep 17 00:00:00 2001 From: Urtzi Alfaro Date: Wed, 17 Dec 2025 16:22:39 +0100 Subject: [PATCH] CRITICAL FIX: Add missing demo_account_type to gateway middleware MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The gateway middleware was not including demo_account_type in the request.state.user context, causing the tenant API to filter with an empty account type. ## The Bug: Gateway middleware set: - demo_session_id ✅ - is_demo ✅ - demo_account_type ❌ MISSING! This caused get_virtual_tenants_for_session() to be called with demo_account_type="" (empty string), which returned only the parent tenant instead of parent + 5 children. ## Log Evidence: Before fix: Demo session detected for get_user_tenants demo_account_type= ← EMPTY! tenant_count=1 ← Only parent! After fix (expected): Demo session detected for get_user_tenants demo_account_type=enterprise tenant_count=6 ← Parent + 5 children! ## Fix: Added line 211 in gateway/app/middleware/demo_middleware.py: "demo_account_type": session_info.get("demo_account_type", "professional") This ensures the tenant service knows whether it's an enterprise or professional demo session and returns the correct tenant list. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- gateway/app/middleware/demo_middleware.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gateway/app/middleware/demo_middleware.py b/gateway/app/middleware/demo_middleware.py index 3996c54d..23ee8c52 100644 --- a/gateway/app/middleware/demo_middleware.py +++ b/gateway/app/middleware/demo_middleware.py @@ -208,6 +208,7 @@ class DemoMiddleware(BaseHTTPMiddleware): "role": "owner", # Demo users have owner role "is_demo": True, "demo_session_id": session_id, + "demo_account_type": session_info.get("demo_account_type", "professional"), "demo_session_status": current_status }