Skip to content

Commit 5d5e572

Browse files
committed
build
1 parent 963e98f commit 5d5e572

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

cli.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,20 @@ def _check_required_keys(agent_initialization=False):
192192
border_style="yellow"
193193
))
194194

195-
# Check which keys can be stored securely
196-
secure_storage_available = keyring_available and config.get("use_keyring", True)
197-
secure_status = config.securely_stored_keys() if secure_storage_available else {}
195+
# Check which keys can be stored securely - safely handle different config types
196+
secure_storage_available = keyring_available
197+
secure_status = {}
198+
199+
# Only try to call securely_stored_keys if the config object might have this method
200+
if hasattr(config, 'securely_stored_keys') and callable(getattr(config, 'securely_stored_keys', None)):
201+
try:
202+
secure_status = config.securely_stored_keys()
203+
except Exception:
204+
# Fall back to assuming no secure storage if method fails
205+
secure_status = {}
206+
else:
207+
# This is likely an old version or different implementation
208+
secure_storage_available = False
198209

199210
for key, display_name in required_keys.items():
200211
if key not in missing_keys:
@@ -437,9 +448,16 @@ def config(api_key, serper_key, timeout, format, use_keyring, show):
437448

438449
if show:
439450
click.echo("Current configuration:")
440-
secure_keys = config.securely_stored_keys() if secure_storage else {}
441451

442-
for key, value in config.items():
452+
# Safely handle different config types
453+
secure_keys = {}
454+
if hasattr(config, 'securely_stored_keys') and callable(getattr(config, 'securely_stored_keys', None)):
455+
try:
456+
secure_keys = config.securely_stored_keys()
457+
except Exception:
458+
secure_keys = {}
459+
460+
for key, value in (config.items() if hasattr(config, 'items') else config.get_all().items()):
443461
if key.endswith('_api_key') and value:
444462
value = f"{value[:4]}...{value[-4:]}"
445463
storage_info = " [stored in system keyring]" if secure_keys.get(key, False) else ""

0 commit comments

Comments
 (0)