mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(cli): prevent TypeError on startup when base_url is None (#3068)
Description This PR fixes the startup crash introduced in v0.4.0 where `self.base_url` being `None` throws a `TypeError`. Root Cause: At `cli.py:1108`, a membership check (`"openrouter.ai" in self.base_url`) is performed. If a user's config doesn't explicitly set a `base_url` (meaning it's `None`), Python raises a `TypeError: argument of type 'NoneType' is not iterable`, causing the entire CLI to crash on boot. Fix: Added a simple truthiness guard (`if self.base_url and ...`) to ensure the membership check only occurs if `base_url` is a valid string. Closes #2842 Co-authored-by: devorun <130918800+devorun@users.noreply.github.com>
This commit is contained in:
parent
37cabc47d3
commit
9d1e13019e
1 changed files with 1 additions and 1 deletions
2
cli.py
2
cli.py
|
|
@ -1093,7 +1093,7 @@ class HermesCLI:
|
||||||
# Match key to resolved base_url: OpenRouter URL → prefer OPENROUTER_API_KEY,
|
# Match key to resolved base_url: OpenRouter URL → prefer OPENROUTER_API_KEY,
|
||||||
# custom endpoint → prefer OPENAI_API_KEY (issue #560).
|
# custom endpoint → prefer OPENAI_API_KEY (issue #560).
|
||||||
# Note: _ensure_runtime_credentials() re-resolves this before first use.
|
# Note: _ensure_runtime_credentials() re-resolves this before first use.
|
||||||
if "openrouter.ai" in self.base_url:
|
if self.base_url and "openrouter.ai" in self.base_url:
|
||||||
self.api_key = api_key or os.getenv("OPENROUTER_API_KEY") or os.getenv("OPENAI_API_KEY")
|
self.api_key = api_key or os.getenv("OPENROUTER_API_KEY") or os.getenv("OPENAI_API_KEY")
|
||||||
else:
|
else:
|
||||||
self.api_key = api_key or os.getenv("OPENAI_API_KEY") or os.getenv("OPENROUTER_API_KEY")
|
self.api_key = api_key or os.getenv("OPENAI_API_KEY") or os.getenv("OPENROUTER_API_KEY")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue