From 497bca8684d77cd0242eddea6162b2986b976f80 Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Sun, 10 May 2026 15:48:09 -0400 Subject: [PATCH] fix(ui): surface Plus OAuth credential diagnostics in Add Account dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When POST /api/cliproxy/auth/:provider/start-url returns 400 plus_oauth_credentials_missing or 502 plus_oauth_url_missing_client_id, surface the server-provided human-readable message (env var names and backend=original switch hint) instead of the raw error code. Error propagates through the existing toast/inline-alert path in add-account-dialog.tsx — no new component primitives. Refs #1208 --- ui/src/hooks/use-cliproxy-auth-flow.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ui/src/hooks/use-cliproxy-auth-flow.ts b/ui/src/hooks/use-cliproxy-auth-flow.ts index b9dca50d..bba9788a 100644 --- a/ui/src/hooks/use-cliproxy-auth-flow.ts +++ b/ui/src/hooks/use-cliproxy-auth-flow.ts @@ -371,8 +371,17 @@ export function useCliproxyAuthFlow() { const success = data.success === true; if (!response.ok || !success) { + // For Plus OAuth credential errors the server sends a human-readable + // explanation in `data.message`; prefer it over the machine error code. + const isPlusCredentialError = + data.error === 'plus_oauth_credentials_missing' || + data.error === 'plus_oauth_url_missing_client_id'; const errorMsg = - typeof data.error === 'string' ? data.error : t('toasts.providerStartOAuthFailed'); + isPlusCredentialError && typeof data.message === 'string' + ? data.message + : typeof data.error === 'string' + ? data.error + : t('toasts.providerStartOAuthFailed'); throw new Error(errorMsg); }