fix: guard float()/int() env var casts against non-numeric input - #35790
Closed
annguyenNous wants to merge 1 commit into
Closed
fix: guard float()/int() env var casts against non-numeric input#35790annguyenNous wants to merge 1 commit into
annguyenNous wants to merge 1 commit into
Conversation
Multiple platform adapters and the streaming helpers cast env vars via float()/int() without try/except. A non-numeric env var value (e.g. "abc") causes an unhandled ValueError that crashes the adapter initialization or streaming code path. Fixed locations: - agent/chat_completion_helpers.py: 4 bare float()/int() calls replaced with _env_float() helper or inline try/except - plugins/platforms/irc/adapter.py: IRC_PORT int() guard - plugins/platforms/google_chat/adapter.py: 2 int() guards - plugins/platforms/discord/adapter.py: 2 float() guards - plugins/browser/firecrawl/provider.py: FIRECRAWL_BROWSER_TTL guard
Collaborator
tonydwb
approved these changes
May 31, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary — PR #35790
Verdict: Approved ✅
Author: annguyenNous | Type: bugfix | Files: 5 files, 31 additions, 10 deletions
Findings
- Correct defensive pattern: routes bare
float()through existing_env_float()helper inchat_completion_helpers.py(2 calls), wrapsint()intry/except (ValueError, TypeError)for remaining 4 files. - Covers 7 env variable casts across streaming helpers (
HERMES_API_TIMEOUT,HERMES_STREAM_READ_TIMEOUT,HERMES_STREAM_RETRIES,HERMES_STREAM_STALE_TIMEOUT) and 4 platform adapters (Discord batch delays, Google Chat flow control, IRC port, Firecrawl browser TTL). - Matches existing pattern in
send_message_tool.py,terminal_tool.py,line/adapter.py. - Non-numeric env vars now fall back to sensible defaults instead of crashing.
No issues found.
Reviewed by Hermes Agent
This was referenced Jun 13, 2026
Contributor
|
Thanks for the defensive coverage. This automated hermes-sweeper review found that current
The member comment noting overlap with #30274 is consistent with the shared implementation now on main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Guard
float()/int()env var casts across 6 filesMultiple platform adapters and streaming helpers cast environment variables via
float()/int()withouttry/except. Setting any of these env vars to a non-numeric string (e.g."abc") causes an unhandledValueErrorthat crashes adapter initialization or the streaming code path.Files changed
agent/chat_completion_helpers.pyHERMES_API_TIMEOUT,HERMES_STREAM_READ_TIMEOUT,HERMES_STREAM_RETRIES,HERMES_STREAM_STALE_TIMEOUTplugins/platforms/irc/adapter.pyIRC_PORTplugins/platforms/google_chat/adapter.pyGOOGLE_CHAT_MAX_MESSAGES,GOOGLE_CHAT_MAX_BYTESplugins/platforms/discord/adapter.pyHERMES_DISCORD_TEXT_BATCH_DELAY_SECONDS,HERMES_DISCORD_TEXT_BATCH_SPLIT_DELAY_SECONDSplugins/browser/firecrawl/provider.pyFIRECRAWL_BROWSER_TTLPattern
For
chat_completion_helpers.py, the file already has a_env_float()helper — the 2 barefloat()calls are now routed through it. Forint()locations, inlinetry/except (ValueError, TypeError)with default fallback is used, matching the existing defensive pattern insend_message_tool.py,terminal_tool.py, andline/adapter.py.