From bc0913ba7c7ee7cbc5fc5c3c20e687640d54abec Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 22 Aug 2025 12:38:41 +1000 Subject: [PATCH] fix(ui): race condition when setting hf token and downloading model I ran into a race condition where I set a HF token and it was valid, but somehow this error toast still appeared. The conditional feel through to an assertion that we never expected to get to, which crashed the UI. Handled the unexpected case gracefully now. --- .../web/src/services/events/onModelInstallError.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/invokeai/frontend/web/src/services/events/onModelInstallError.tsx b/invokeai/frontend/web/src/services/events/onModelInstallError.tsx index 23089ca4102..0cb77e294c4 100644 --- a/invokeai/frontend/web/src/services/events/onModelInstallError.tsx +++ b/invokeai/frontend/web/src/services/events/onModelInstallError.tsx @@ -173,7 +173,7 @@ const HFUnauthorizedToastDescription = () => { if (data === 'unknown') { return ( - {t('modelManager.hfTokenUnableToErrorMessage')}{' '} + {t('modelManager.hfTokenUnableToVerifyErrorMessage')}{' '} @@ -181,6 +181,13 @@ const HFUnauthorizedToastDescription = () => { ); } - // data === 'valid' - should never happen! - assert(false, 'Unexpected valid HF token with unauthorized error'); + // data === 'valid' - user may have a token but not authorized for model? + return ( + + {t('modelManager.hfTokenForbiddenErrorMessage')}{' '} + + + ); };