From e94b4b2b4016d77d2c76fce496a2c825e74e306c Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Thu, 2 Apr 2026 12:58:08 +0530 Subject: [PATCH] fix: preserve allowed_users during setup reconfigure and quiet unconfigured provider warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Setup wizard now shows existing allowed_users when reconfiguring a platform and preserves them if the user presses Enter. Previously the wizard would display a misleading "No allowlist set" warning even when the .env still held the original IDs. Also downgrades the "provider X has no API key configured" log from WARNING to DEBUG in resolve_provider_client — callers already handle the None return with their own contextual messages. This eliminates noisy startup warnings for providers in the fallback chain that the user never configured (e.g. minimax). --- agent/auxiliary_client.py | 6 ++--- hermes_cli/setup.py | 55 +++++++++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 8 deletions(-) diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py index 3b05e8d12..bfbf20b5d 100644 --- a/agent/auxiliary_client.py +++ b/agent/auxiliary_client.py @@ -1078,9 +1078,9 @@ def resolve_provider_client( tried_sources = list(pconfig.api_key_env_vars) if provider == "copilot": tried_sources.append("gh auth token") - logger.warning("resolve_provider_client: provider %s has no API " - "key configured (tried: %s)", - provider, ", ".join(tried_sources)) + logger.debug("resolve_provider_client: provider %s has no API " + "key configured (tried: %s)", + provider, ", ".join(tried_sources)) return None, None base_url = str(creds.get("base_url", "")).strip().rstrip("/") or pconfig.inference_base_url diff --git a/hermes_cli/setup.py b/hermes_cli/setup.py index 2e0f0ad32..b0247109c 100644 --- a/hermes_cli/setup.py +++ b/hermes_cli/setup.py @@ -1808,14 +1808,23 @@ def setup_gateway(config: dict): print_info(" 1. Message @userinfobot on Telegram") print_info(" 2. It will reply with your numeric ID (e.g., 123456789)") print() + existing_allowlist = get_env_value("TELEGRAM_ALLOWED_USERS") + if existing_allowlist: + print_info(f" Current allowlist: {existing_allowlist}") allowed_users = prompt( - "Allowed user IDs (comma-separated, leave empty for open access)" + "Allowed user IDs (comma-separated, leave empty to " + + ("keep current" if existing_allowlist else "allow open access") + + ")" ) if allowed_users: save_env_value("TELEGRAM_ALLOWED_USERS", allowed_users.replace(" ", "")) print_success( "Telegram allowlist configured - only listed users can use the bot" ) + elif existing_allowlist: + print_success( + f"Keeping existing Telegram allowlist: {existing_allowlist}" + ) else: print_info( "⚠️ No allowlist set - anyone who finds your bot can use it!" @@ -1887,8 +1896,13 @@ def setup_gateway(config: dict): " You can also use Discord usernames (resolved on gateway start)." ) print() + existing_allowlist = get_env_value("DISCORD_ALLOWED_USERS") + if existing_allowlist: + print_info(f" Current allowlist: {existing_allowlist}") allowed_users = prompt( - "Allowed user IDs or usernames (comma-separated, leave empty for open access)" + "Allowed user IDs or usernames (comma-separated, leave empty to " + + ("keep current" if existing_allowlist else "allow open access") + + ")" ) if allowed_users: # Clean up common prefixes (user:123, <@123>, <@!123>) @@ -1903,6 +1917,10 @@ def setup_gateway(config: dict): cleaned_ids.append(uid) save_env_value("DISCORD_ALLOWED_USERS", ",".join(cleaned_ids)) print_success("Discord allowlist configured") + elif existing_allowlist: + print_success( + f"Keeping existing Discord allowlist: {existing_allowlist}" + ) else: print_info( "⚠️ No allowlist set - anyone in servers with your bot can use it!" @@ -1999,12 +2017,21 @@ def setup_gateway(config: dict): " To find a Member ID: click a user's name → View full profile → ⋮ → Copy member ID" ) print() + existing_allowlist = get_env_value("SLACK_ALLOWED_USERS") + if existing_allowlist: + print_info(f" Current allowlist: {existing_allowlist}") allowed_users = prompt( - "Allowed user IDs (comma-separated, leave empty to deny everyone except paired users)" + "Allowed user IDs (comma-separated, leave empty to " + + ("keep current" if existing_allowlist else "deny everyone except paired users") + + ")" ) if allowed_users: save_env_value("SLACK_ALLOWED_USERS", allowed_users.replace(" ", "")) print_success("Slack allowlist configured") + elif existing_allowlist: + print_success( + f"Keeping existing Slack allowlist: {existing_allowlist}" + ) else: print_warning( "⚠️ No Slack allowlist set - unpaired users will be denied by default." @@ -2088,12 +2115,21 @@ def setup_gateway(config: dict): print_info("🔒 Security: Restrict who can use your bot") print_info(" Matrix user IDs look like @username:server") print() + existing_allowlist = get_env_value("MATRIX_ALLOWED_USERS") + if existing_allowlist: + print_info(f" Current allowlist: {existing_allowlist}") allowed_users = prompt( - "Allowed user IDs (comma-separated, leave empty for open access)" + "Allowed user IDs (comma-separated, leave empty to " + + ("keep current" if existing_allowlist else "allow open access") + + ")" ) if allowed_users: save_env_value("MATRIX_ALLOWED_USERS", allowed_users.replace(" ", "")) print_success("Matrix allowlist configured") + elif existing_allowlist: + print_success( + f"Keeping existing Matrix allowlist: {existing_allowlist}" + ) else: print_info( "⚠️ No allowlist set - anyone who can message the bot can use it!" @@ -2134,12 +2170,21 @@ def setup_gateway(config: dict): print_info(" To find your user ID: click your avatar → Profile") print_info(" or use the API: GET /api/v4/users/me") print() + existing_allowlist = get_env_value("MATTERMOST_ALLOWED_USERS") + if existing_allowlist: + print_info(f" Current allowlist: {existing_allowlist}") allowed_users = prompt( - "Allowed user IDs (comma-separated, leave empty for open access)" + "Allowed user IDs (comma-separated, leave empty to " + + ("keep current" if existing_allowlist else "allow open access") + + ")" ) if allowed_users: save_env_value("MATTERMOST_ALLOWED_USERS", allowed_users.replace(" ", "")) print_success("Mattermost allowlist configured") + elif existing_allowlist: + print_success( + f"Keeping existing Mattermost allowlist: {existing_allowlist}" + ) else: print_info( "⚠️ No allowlist set - anyone who can message the bot can use it!"