mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(tools): guard against ValueError on int() env var and header parsing
Three locations perform `int()` conversion on environment variables or HTTP headers without error handling, causing unhandled `ValueError` crashes when the values are non-numeric: 1. `send_message_tool.py` — `EMAIL_SMTP_PORT` env var parsed outside the try/except block; a non-numeric value crashes `_send_email()` instead of returning a user-friendly error. 2. `process_registry.py` — `TERMINAL_TIMEOUT` env var parsed without protection; a non-numeric value crashes the `wait()` method. 3. `skills_hub.py` — HTTP `Retry-After` header can contain date strings per RFC 7231; `int()` conversion crashes on non-numeric values. All three now fall back to their default values on `ValueError`/`TypeError`.
This commit is contained in:
parent
6f63ba9c8f
commit
c1f832a610
3 changed files with 12 additions and 3 deletions
|
|
@ -689,7 +689,10 @@ async def _send_email(extra, chat_id, message):
|
|||
address = extra.get("address") or os.getenv("EMAIL_ADDRESS", "")
|
||||
password = os.getenv("EMAIL_PASSWORD", "")
|
||||
smtp_host = extra.get("smtp_host") or os.getenv("EMAIL_SMTP_HOST", "")
|
||||
smtp_port = int(os.getenv("EMAIL_SMTP_PORT", "587"))
|
||||
try:
|
||||
smtp_port = int(os.getenv("EMAIL_SMTP_PORT", "587"))
|
||||
except (ValueError, TypeError):
|
||||
smtp_port = 587
|
||||
|
||||
if not all([address, password, smtp_host]):
|
||||
return {"error": "Email not configured (EMAIL_ADDRESS, EMAIL_PASSWORD, EMAIL_SMTP_HOST required)"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue