Skip to content

fix(feishu): guard 6 env var casts against malformed values - #48771

Closed
vanthinh6886 wants to merge 1 commit into
NousResearch:mainfrom
vanthinh6886:fix/feishu-env-guards
Closed

fix(feishu): guard 6 env var casts against malformed values#48771
vanthinh6886 wants to merge 1 commit into
NousResearch:mainfrom
vanthinh6886:fix/feishu-env-guards

Conversation

@vanthinh6886

Copy link
Copy Markdown
Contributor

Summary

Replace bare int(os.getenv)/float(os.getenv) with env_int()/env_float() for 6 env vars in gateway/platforms/feishu.py:

  • HERMES_FEISHU_DEDUP_CACHE_SIZE (int)
  • HERMES_FEISHU_TEXT_BATCH_DELAY_SECONDS (float)
  • HERMES_FEISHU_TEXT_BATCH_SPLIT_DELAY_SECONDS (float)
  • HERMES_FEISHU_TEXT_BATCH_MAX_MESSAGES (int)
  • HERMES_FEISHU_TEXT_BATCH_MAX_CHARS (int)
  • HERMES_FEISHU_MEDIA_BATCH_DELAY_SECONDS (float)

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

Changes

  • gateway/platforms/feishu.py: Add env_int/env_float to existing utils import, replace 6 bare casts

Test Plan

  • Lint clean

Context

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

Replace bare int(os.getenv(...))/float(os.getenv(...)) with
env_int(...)/env_float(...) for 6 env vars in gateway/platforms/feishu.py:

- HERMES_FEISHU_DEDUP_CACHE_SIZE (int)
- HERMES_FEISHU_TEXT_BATCH_DELAY_SECONDS (float)
- HERMES_FEISHU_TEXT_BATCH_SPLIT_DELAY_SECONDS (float)
- HERMES_FEISHU_TEXT_BATCH_MAX_MESSAGES (int)
- HERMES_FEISHU_TEXT_BATCH_MAX_CHARS (int)
- HERMES_FEISHU_MEDIA_BATCH_DELAY_SECONDS (float)

A malformed value (e.g. HERMES_FEISHU_DEDUP_CACHE_SIZE=abc) causes a
ValueError crash when the Feishu adapter initializes. The env_int() and
env_float() helpers in utils.py catch ValueError/TypeError and return
the default value.
@vanthinh6886
vanthinh6886 force-pushed the fix/feishu-env-guards branch from 542408a to 5e175be Compare June 19, 2026 03:00

@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

Consistent defensive fix: guards env var casts against malformed values in the Feishu platform adapter. 18 additions across affected files. 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 P2 Medium — degraded but workaround exists platform/feishu Feishu / Lark adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants