mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-18 14:52:04 +00:00
fix(agent): guard .get(key, "").method() None dereference in adapters
dict.get(key, default) returns None (not the default) when the key EXISTS with value None. The default only applies when the key is ABSENT. Chained method calls (.strip(), .upper(), .count()) crash with AttributeError on NoneType. Fix two confirmed hits: - auxiliary_client.py: custom provider base_url/api_key (config null) - anthropic_adapter.py: text block content (API null response) Pattern: .get(key, "").method() → (.get(key) or "").method()
This commit is contained in:
parent
5e50f18b30
commit
838aa742cb
2 changed files with 3 additions and 3 deletions
|
|
@ -2102,7 +2102,7 @@ def _convert_user_message(content: Any) -> Dict[str, Any]:
|
|||
if isinstance(content, list):
|
||||
converted_blocks = _convert_content_to_anthropic(content)
|
||||
if not converted_blocks or all(
|
||||
b.get("text", "").strip() == ""
|
||||
(b.get("text") or "").strip() == ""
|
||||
for b in converted_blocks
|
||||
if isinstance(b, dict) and b.get("type") == "text"
|
||||
):
|
||||
|
|
|
|||
|
|
@ -4716,8 +4716,8 @@ def resolve_provider_client(
|
|||
if custom_entry is None:
|
||||
custom_entry = _get_named_custom_provider(provider)
|
||||
if custom_entry:
|
||||
custom_base = custom_entry.get("base_url", "").strip()
|
||||
custom_key = custom_entry.get("api_key", "").strip()
|
||||
custom_base = (custom_entry.get("base_url") or "").strip()
|
||||
custom_key = (custom_entry.get("api_key") or "").strip()
|
||||
custom_key_env = (custom_entry.get("key_env") or custom_entry.get("api_key_env") or "").strip()
|
||||
if not custom_key and custom_key_env:
|
||||
custom_key = os.getenv(custom_key_env, "").strip()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue