fix(agent/discord): use safe env-float helper consistently - #40938
Closed
annguyenNous wants to merge 1 commit into
Closed
fix(agent/discord): use safe env-float helper consistently#40938annguyenNous wants to merge 1 commit into
annguyenNous wants to merge 1 commit into
Conversation
chat_completion_helpers.py already defines _env_float() (line 118) that guards against non-numeric env var values, but 3 call sites still use bare float(os.getenv(...)): - HERMES_API_TIMEOUT (line 1683) - HERMES_STREAM_READ_TIMEOUT (line 1690) - HERMES_STREAM_STALE_TIMEOUT (line 2296) Also: plugins/platforms/discord/adapter.py uses bare float(os.getenv()) for HERMES_DISCORD_TEXT_BATCH_DELAY_SECONDS and HERMES_DISCORD_TEXT_BATCH_SPLIT_DELAY_SECONDS without any guard. A non-numeric value in any of these crashes the agent or gateway. Fix by using _env_float() (chat_completion_helpers) or a local _safe_float_env() helper (discord adapter).
Contributor
|
Thanks for identifying the unguarded environment parsing cases. Automated hermes-sweeper review found that the requested behavior is already on current
Closing as implemented 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.
Bug
chat_completion_helpers.pyalready defines_env_float()(line 118) that guards against non-numeric env var values with atry/except (ValueError, TypeError)fallback. But 3 call sites in the same file still use barefloat(os.getenv(...)):HERMES_API_TIMEOUT(line 1683)HERMES_STREAM_READ_TIMEOUT(line 1690)HERMES_STREAM_STALE_TIMEOUT(line 2296)Additionally,
plugins/platforms/discord/adapter.pyuses barefloat(os.getenv())for:HERMES_DISCORD_TEXT_BATCH_DELAY_SECONDS(line 591)HERMES_DISCORD_TEXT_BATCH_SPLIT_DELAY_SECONDS(line 592)A non-numeric value in any of these env vars crashes the agent or gateway with
ValueError.Fix
chat_completion_helpers.py: Replace 3 barefloat(os.getenv(...))calls with the existing_env_float()helperdiscord/adapter.py: Add local_safe_float_env()helper and use it for the 2 callsThis is Pitfall 30 from the codebase patterns: "File has a safe helper but doesn't use it internally."