From 1b3be0437d9f052015ccda5a6bff4b863ecbc77f Mon Sep 17 00:00:00 2001 From: Thigazhezhilan J Date: Sat, 2 May 2026 15:34:09 +0530 Subject: [PATCH] Gracefully handle missing pyotp so backend always starts --- backend/app/services/auto_login_service.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/app/services/auto_login_service.py b/backend/app/services/auto_login_service.py index 8d1c773..11957d8 100644 --- a/backend/app/services/auto_login_service.py +++ b/backend/app/services/auto_login_service.py @@ -198,7 +198,10 @@ def _perform_zerodha_login( request_id = login_data["data"]["request_id"] # Step 2: TOTP — don't follow redirect automatically - import pyotp # imported here so missing package doesn't crash startup + try: + import pyotp + except ImportError: + raise AutoLoginError("pyotp is not installed on the server. Run: pip install pyotp==2.9.0") totp_value = pyotp.TOTP(totp_secret).now() twofa_resp = session.post( KITE_TWOFA_ENDPOINT,