fix(gateway): also tolerate malformed env vars in custom human-delay mode
Widens @Krionex's PR #16933 fix to cover the second bug class at the sibling site. natural mode used to pass env values through int() before the PR caught mis-typed values crashing the gateway; custom mode had the exact same bug one branch away (HERMES_HUMAN_DELAY_MIN_MS=oops in custom mode still crashed). Same try/except/fallback pattern, scoped to the two int() calls that feed random.uniform().
This commit is contained in:
@@ -512,6 +512,17 @@ class TestGetHumanDelay:
|
||||
delay = BasePlatformAdapter._get_human_delay()
|
||||
assert 0.1 <= delay <= 0.2
|
||||
|
||||
def test_custom_mode_tolerates_malformed_env_vars(self):
|
||||
env = {
|
||||
"HERMES_HUMAN_DELAY_MODE": "custom",
|
||||
"HERMES_HUMAN_DELAY_MIN_MS": "oops",
|
||||
"HERMES_HUMAN_DELAY_MAX_MS": "still-bad",
|
||||
}
|
||||
with patch.dict(os.environ, env):
|
||||
# falls back to the custom-mode defaults instead of crashing
|
||||
delay = BasePlatformAdapter._get_human_delay()
|
||||
assert 0.8 <= delay <= 2.5
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# utf16_len / _prefix_within_utf16_limit / truncate_message with len_fn
|
||||
|
||||
Reference in New Issue
Block a user