From d7452af257b94287d98825c9a23eaaf2eea3da66 Mon Sep 17 00:00:00 2001 From: sharziki Date: Fri, 10 Apr 2026 21:50:29 -0400 Subject: [PATCH] fix(pairing): handle null user_name in pairing list display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When user_name is stored as None (e.g. Telegram users without a display name), dict.get('user_name', '') returns None because the key exists — the default is only used for missing keys. This causes a TypeError when the format specifier :<20 is applied to None. Use `or ''` to coerce None to an empty string. Fixes #7392 Co-Authored-By: Claude Opus 4.6 --- hermes_cli/pairing.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hermes_cli/pairing.py b/hermes_cli/pairing.py index 7e04da902..887b7e49f 100644 --- a/hermes_cli/pairing.py +++ b/hermes_cli/pairing.py @@ -44,7 +44,7 @@ def _cmd_list(store): for p in pending: print( f" {p['platform']:<12} {p['code']:<10} {p['user_id']:<20} " - f"{p.get('user_name', ''):<20} {p['age_minutes']}m ago" + f"{(p.get('user_name') or ''):<20} {p['age_minutes']}m ago" ) else: print("\n No pending pairing requests.") @@ -54,7 +54,7 @@ def _cmd_list(store): print(f" {'Platform':<12} {'User ID':<20} {'Name':<20}") print(f" {'--------':<12} {'-------':<20} {'----':<20}") for a in approved: - print(f" {a['platform']:<12} {a['user_id']:<20} {a.get('user_name', ''):<20}") + print(f" {a['platform']:<12} {a['user_id']:<20} {(a.get('user_name') or ''):<20}") else: print("\n No approved users.") @@ -69,7 +69,7 @@ def _cmd_approve(store, platform: str, code: str): result = store.approve_code(platform, code) if result: uid = result["user_id"] - name = result.get("user_name", "") + name = result.get("user_name") or "" display = f"{name} ({uid})" if name else uid print(f"\n Approved! User {display} on {platform} can now use the bot~") print(" They'll be recognized automatically on their next message.\n")