fix: guard missing env vars in authenticate(), drain queues post-yield

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christophe Vila
2026-05-17 19:43:38 +02:00
parent 170d7ce37d
commit 6b38f17e9b
2 changed files with 36 additions and 11 deletions

View File

@@ -50,6 +50,11 @@ def authenticate() -> str:
"""Initiate Garmin authentication using credentials from environment variables."""
global _client, _auth_state
email = os.environ.get("GARMIN_EMAIL", "")
password = os.environ.get("GARMIN_PASSWORD", "")
if not email or not password:
return "GARMIN_EMAIL and GARMIN_PASSWORD environment variables are required."
def _do_login() -> None:
try:
_client.login()
@@ -57,7 +62,7 @@ def authenticate() -> str:
except Exception as exc:
_login_result_queue.put(("error", str(exc)))
_client = Garmin(os.environ.get("GARMIN_EMAIL", ""), os.environ.get("GARMIN_PASSWORD", ""))
_client = Garmin(email, password)
_client.prompt_mfa = _prompt_mfa
threading.Thread(target=_do_login, daemon=True).start()