Skip to content

fix(wecom): guard text batch delay env vars against malformed values - #48757

Closed
vanthinh6886 wants to merge 1 commit into
NousResearch:mainfrom
vanthinh6886:fix/wecom-delay-env-guard
Closed

fix(wecom): guard text batch delay env vars against malformed values#48757
vanthinh6886 wants to merge 1 commit into
NousResearch:mainfrom
vanthinh6886:fix/wecom-delay-env-guard

Conversation

@vanthinh6886

Copy link
Copy Markdown
Contributor

Summary

Replace bare float(os.getenv(...)) with env_float(...) for 2 env vars in gateway/platforms/wecom.py:

  • HERMES_WECOM_TEXT_BATCH_DELAY_SECONDS (line 189)
  • HERMES_WECOM_TEXT_BATCH_SPLIT_DELAY_SECONDS (line 190)

A malformed value causes a ValueError crash when the WeCom adapter initializes.

Changes

  • gateway/platforms/wecom.py: Add env_float import from utils, replace 2 bare float(os.getenv) calls

Test Plan

  • Lint clean

Context

Part of systemic env var guard issue. Related: PR #48735, #48740, #48745, #48748.

Replace bare float(os.getenv(...)) with env_float(...) for 2 env vars
in gateway/platforms/wecom.py __init__:

- HERMES_WECOM_TEXT_BATCH_DELAY_SECONDS (line 189)
- HERMES_WECOM_TEXT_BATCH_SPLIT_DELAY_SECONDS (line 190)

A malformed value (e.g. HERMES_WECOM_TEXT_BATCH_DELAY_SECONDS=abc)
causes a ValueError crash when the WeCom adapter initializes.
The env_float() helper in utils.py catches ValueError/TypeError and
returns the default value.
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/wecom WeCom / WeChat Work adapter P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jun 19, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #23374 — same fix: guards the WeCom text batch-delay env vars (HERMES_WECOM_TEXT_BATCH_DELAY_SECONDS / _SPLIT_DELAY_SECONDS) against malformed values. #23374 (earliest open) already hardens these exact batch-delay env parses across Telegram/Discord/WeCom; see also the broader open cluster #47338/#39113. Closing as redundant.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Guards wecom text batch delay env vars against malformed values. Consistent with the env-var guard pattern established in this batch. 3 additions. No concerns.


Reviewed by Hermes Agent

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Closing as superseded by #49558, which landed the canonical fix for this whole bug class.

#49558 adds env_float() alongside the existing env_int() in utils.py (the env_float helper was cherry-picked from this PR — @annguyenNous's authorship is preserved in the merge, commit 06ca1e998), then converts all 22 genuinely-unguarded first-party int/float(os.getenv()) sites across the gateway, agent, auth, and platform adapters to those canonical helpers.

We went with the utils.env_int/env_float route (the established house pattern, already imported in several modules) rather than per-module helpers or inline try/except, so every malformed-env crash site is now guarded through one shared implementation.

Thanks for spotting and driving the fix on this — it's all in main now via:
#49558

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have platform/wecom WeCom / WeChat Work adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants