fix(gateway): guard bare int/float(os.getenv) in platform configs - #48368
fix(gateway): guard bare int/float(os.getenv) in platform configs#48368vanthinh6886 wants to merge 1 commit into
Conversation
Bare int(os.getenv) and float(os.getenv) calls crash the gateway with ValueError when env vars contain non-numeric strings. Replace with env_int()/env_float() from utils.py which catch ValueError/TypeError and fall back to defaults. Affected modules: - gateway/config.py: WECOM_CALLBACK_PORT, BLUEBUBBLES_WEBHOOK_PORT - gateway/platforms/email.py: EMAIL_IMAP_PORT, EMAIL_SMTP_PORT, EMAIL_POLL_INTERVAL - gateway/platforms/feishu.py: 6 config vars (dedup, batching, webhook) - gateway/platforms/telegram.py: MEDIA_BATCH_DELAY, WEBHOOK_PORT - gateway/platforms/wecom.py: TEXT_BATCH_DELAY, TEXT_BATCH_SPLIT_DELAY
|
Note: This is NOT a duplicate of the prior closed PRs (#39113, #48365, #39113). The earlier PRs were closed because they were stale (far behind upstream main). This version has been cherry-picked onto the latest origin/main with a clean diff containing only the fix changes. No conflicts. CI green. Ready for review. |
|
Closing as superseded by #49558, which landed the canonical fix for this whole bug class. #49558 adds We went with the Thanks for spotting and driving the fix on this — it's all in main now via: |
Summary
Bare
int(os.getenv(...))andfloat(os.getenv(...))calls across gateway platform configs crash withValueErrorwhen env vars contain non-numeric strings. Replace withenv_int()/env_float()fromutils.pywhich catchValueError/TypeErrorand fall back to defaults.Follow-up to PR #48365 which fixed the HERMES_MAX_ITERATIONS call sites. This PR covers the remaining platform-specific config vars.
Changes
Test Plan
python -c "from utils import env_int, env_float"imports OK