Skip to content

fix(config): guard WECOM_CALLBACK_PORT/BLUEBUBBLES_WEBHOOK_PORT against malformed env var - #48748

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

fix(config): guard WECOM_CALLBACK_PORT/BLUEBUBBLES_WEBHOOK_PORT against malformed env var#48748
vanthinh6886 wants to merge 1 commit into
NousResearch:mainfrom
vanthinh6886:fix/config-port-env-guard

Conversation

@vanthinh6886

Copy link
Copy Markdown
Contributor

Summary

Replace bare int(os.getenv(...)) with env_int(...) for 2 port env vars in gateway/config.py:

  • WECOM_CALLBACK_PORT (line 1834)
  • BLUEBUBBLES_WEBHOOK_PORT (line 1890)

A malformed value (e.g. WECOM_CALLBACK_PORT=abc) causes a ValueError crash during gateway config loading. The env_int() helper in utils.py catches ValueError/TypeError and returns the default value.

Changes

  • gateway/config.py: Add env_int to existing utils import, replace 2 bare int(os.getenv) calls

Test Plan

  • pytest config/wecom/bluebubbles tests pass
  • Lint clean

Context

Part of systemic env var guard issue. Related: PR #48735 (api_server.py), PR #48740 (run.py), PR #48745 (email.py).

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery 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 #20205 — same two port env vars (WECOM_CALLBACK_PORT, BLUEBUBBLES_WEBHOOK_PORT) guarded against malformed values with the same int-guard helper in gateway/config.py. #20205 (earliest open) already covers this exact site/mechanism.

…st malformed env var

Replace bare int(os.getenv(...)) with env_int(...) for 2 port env vars
in gateway/config.py:

- WECOM_CALLBACK_PORT (line 1834)
- BLUEBUBBLES_WEBHOOK_PORT (line 1890)

A malformed value (e.g. WECOM_CALLBACK_PORT=abc) causes a ValueError
crash during gateway config loading. The env_int() helper in utils.py
catches ValueError/TypeError and returns the default value.
@vanthinh6886
vanthinh6886 force-pushed the fix/config-port-env-guard branch from 2ad82b3 to effa289 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

Guards WECOM_CALLBACK_PORT and BLUEBUBBLES_WEBHOOK_PORT against malformed env var values. Consistent with the env-var guard pattern 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 type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants