From 7ea09fe49dd40f73c4dbf4eda76ff3a21d7f98c3 Mon Sep 17 00:00:00 2001 From: -LAN- Date: Fri, 27 Feb 2026 18:48:15 +0800 Subject: [PATCH] fix(type): narrow change-email phase lookup --- api/controllers/console/workspace/account.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/controllers/console/workspace/account.py b/api/controllers/console/workspace/account.py index d935afebaa..ccfb50c214 100644 --- a/api/controllers/console/workspace/account.py +++ b/api/controllers/console/workspace/account.py @@ -614,11 +614,13 @@ class ChangeEmailCheckApi(Resource): AccountService.add_change_email_error_rate_limit(user_email) raise EmailCodeError() - phase_transitions = { + phase_transitions: dict[str, str] = { AccountService.CHANGE_EMAIL_PHASE_OLD: AccountService.CHANGE_EMAIL_PHASE_OLD_VERIFIED, AccountService.CHANGE_EMAIL_PHASE_NEW: AccountService.CHANGE_EMAIL_PHASE_NEW_VERIFIED, } token_phase = token_data.get(AccountService.CHANGE_EMAIL_TOKEN_PHASE_KEY) + if not isinstance(token_phase, str): + raise InvalidTokenError() refreshed_phase = phase_transitions.get(token_phase) if refreshed_phase is None: raise InvalidTokenError()