fix(gateway): guard HERMES_MAX_ITERATIONS in run.py against malformed env var - #48740
fix(gateway): guard HERMES_MAX_ITERATIONS in run.py against malformed env var#48740vanthinh6886 wants to merge 1 commit into
Conversation
|
Duplicate of #48298 — both guard the |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Consistent env_int guard application for HERMES_MAX_ITERATIONS in two locations within gateway/run.py. Prevents crashes from malformed env var values. Follows established pattern from other guard fixes in the same codebase.
Reviewed by Hermes Agent
…n run.py
Replace bare int(os.getenv("HERMES_MAX_ITERATIONS", "90")) with
env_int("HERMES_MAX_ITERATIONS", 90) at two call sites in gateway/run.py
(lines 10636 and 14586).
A malformed HERMES_MAX_ITERATIONS env var (e.g. "abc") causes a
ValueError crash. The env_int() helper in utils.py catches
ValueError/TypeError and returns the default value.
Note: Line 4965 already has a try/except guard so it is left as-is.
4f74c0f to
9b6aceb
Compare
|
Closing as already resolved on main. The The remaining malformed-env-var crash sites across the rest of the gateway/agent were just swept up in #49558 (canonical Thanks for the fix — appreciated. |
Summary
Replace bare int(os.getenv("HERMES_MAX_ITERATIONS", "90")) with env_int("HERMES_MAX_ITERATIONS", 90) at two call sites in gateway/run.py (lines 10636 and 14586).
A malformed HERMES_MAX_ITERATIONS env var (e.g. "abc") causes a ValueError crash. The env_int() helper in utils.py catches ValueError/TypeError and returns the default value.
Note: Line 4965 already has a try/except guard so it is left as-is.
Changes
Test Plan
Context
This is part of a systemic issue with ~25 bare int(os.getenv)/float(os.getenv) calls across the gateway. Related: PR #48735 (api_server.py + env_float addition to utils.py).