From 6a958771968c84d72d42121b7acca59ddddab904 Mon Sep 17 00:00:00 2001 From: axelray-dev <110029405+axelray-dev@users.noreply.github.com> Date: Sun, 5 Jul 2026 07:37:29 +0800 Subject: [PATCH] fix(providers): standardize oauth_cli_kit error messages across CLI and WebUI --- nanobot/cli/commands.py | 2 +- nanobot/webui/settings_api.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py index 4c6c3d9a..9bfa9b04 100644 --- a/nanobot/cli/commands.py +++ b/nanobot/cli/commands.py @@ -2401,7 +2401,7 @@ def _logout_github_copilot() -> None: try: from nanobot.providers.github_copilot_provider import get_storage except ImportError: - console.print("[red]GitHub Copilot provider unavailable. Ensure oauth-cli-kit is installed.[/red]") + console.print("[red]oauth_cli_kit not installed. Run: pip install oauth-cli-kit[/red]") raise typer.Exit(1) storage = get_storage() diff --git a/nanobot/webui/settings_api.py b/nanobot/webui/settings_api.py index 5d4d98b5..b00730ff 100644 --- a/nanobot/webui/settings_api.py +++ b/nanobot/webui/settings_api.py @@ -1119,7 +1119,9 @@ def login_oauth_provider(query: QueryParams) -> dict[str, Any]: try: from oauth_cli_kit import get_token, login_oauth_interactive except ImportError: - raise WebUISettingsError("oauth_cli_kit is not installed", status=500) from None + raise WebUISettingsError( + "oauth_cli_kit not installed. Run: pip install oauth-cli-kit", status=500 + ) from None try: proxy = resolve_config_env_vars(load_config()).providers.openai_codex.proxy or None @@ -1146,7 +1148,9 @@ def login_oauth_provider(query: QueryParams) -> dict[str, Any]: login_github_copilot, ) except ImportError: - raise WebUISettingsError("GitHub Copilot OAuth support is unavailable", status=500) from None + raise WebUISettingsError( + "oauth_cli_kit not installed. Run: pip install oauth-cli-kit", status=500 + ) from None token = get_github_copilot_login_status() if not token: @@ -1171,13 +1175,17 @@ def logout_oauth_provider(query: QueryParams) -> dict[str, Any]: from oauth_cli_kit.providers import OPENAI_CODEX_PROVIDER from oauth_cli_kit.storage import FileTokenStorage except ImportError: - raise WebUISettingsError("oauth_cli_kit is not installed", status=500) from None + raise WebUISettingsError( + "oauth_cli_kit not installed. Run: pip install oauth-cli-kit", status=500 + ) from None token_path = FileTokenStorage(token_filename=OPENAI_CODEX_PROVIDER.token_filename).get_token_path() elif spec.name == "github_copilot": try: from nanobot.providers.github_copilot_provider import get_storage except ImportError: - raise WebUISettingsError("GitHub Copilot OAuth support is unavailable", status=500) from None + raise WebUISettingsError( + "oauth_cli_kit not installed. Run: pip install oauth-cli-kit", status=500 + ) from None token_path = get_storage().get_token_path() else: raise WebUISettingsError("OAuth logout is not supported for this provider")