Skip to content

fix(telegram): global dispatcher breaks HTTP proxy for all outbound requests (#26207)#26229

Closed
yinghaosang wants to merge 1 commit intoopenclaw:mainfrom
yinghaosang:fix/telegram-global-dispatcher-proxy
Closed

fix(telegram): global dispatcher breaks HTTP proxy for all outbound requests (#26207)#26229
yinghaosang wants to merge 1 commit intoopenclaw:mainfrom
yinghaosang:fix/telegram-global-dispatcher-proxy

Conversation

@yinghaosang
Copy link
Contributor

@yinghaosang yinghaosang commented Feb 25, 2026

Summary

  • Problem: setGlobalDispatcher(new Agent({...})) in Telegram init replaces the process-wide undici dispatcher with a bare Agent that doesn't respect HTTP_PROXY/HTTPS_PROXY env vars. Users behind proxies (GFW, corporate networks) lose all outbound connectivity after upgrading to 2026.2.24.
  • Why it matters: all globalThis.fetch calls go through this dispatcher — model API, Telegram API, everything.
  • What changed: swapped AgentEnvHttpProxyAgent in src/telegram/fetch.ts. EnvHttpProxyAgent reads proxy env vars when set, falls back to direct connections otherwise. Same autoSelectFamily behavior from fix: resolve Telegram outbound fetch failure on Node 22 (#25676) #25682 is preserved.
  • What did NOT change: per-account Telegram proxy (channels.telegram.proxy) still uses its own ProxyAgent via src/telegram/proxy.ts. No new deps — EnvHttpProxyAgent is already in undici.

lobster-biscuit

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • Integrations

Linked Issue/PR

User-visible / Behavior Changes

Outbound fetch() calls now respect HTTP_PROXY/HTTPS_PROXY/NO_PROXY env vars. No config changes needed — if the env vars aren't set, behavior is identical to a bare Agent.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No — same calls, just routed through proxy when env vars are set
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Root Cause

applyTelegramNetworkWorkarounds() in src/telegram/fetch.ts calls setGlobalDispatcher(new Agent({connect: {autoSelectFamily: ...}})). The bare Agent doesn't read proxy env vars, so any previously-configured proxy-aware dispatcher gets overwritten. Introduced in #25682 to fix IPv6 fallback on Node 22.

Tests

  • Updated 2 existing tests in src/telegram/fetch.test.ts to assert EnvHttpProxyAgent instead of Agent — both fail before fix, pass after
  • All 527 Telegram tests pass (47 test files)
  • pnpm build && pnpm check clean

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery (if this breaks)

  • Revert this single commit. The only change is AgentEnvHttpProxyAgent in one file.
  • Watch for: unexpected proxy routing if a user has stale HTTP_PROXY env vars set that they forgot about.

Risks and Mitigations

  • Risk: EnvHttpProxyAgent picks up proxy env vars that users didn't intend for OpenClaw
    • Mitigation: this matches standard behavior — most HTTP clients respect these env vars. NO_PROXY is also supported for exclusions.

Greptile Summary

Replaced Agent with EnvHttpProxyAgent in src/telegram/fetch.ts to respect HTTP_PROXY/HTTPS_PROXY environment variables when setting the global undici dispatcher. This fixes a regression from #25682 where the bare Agent replaced any proxy-aware dispatcher, breaking outbound connectivity for users behind proxies. The change preserves the existing autoSelectFamily workaround for IPv6 fallback issues on Node 22+ while allowing proxy configuration through standard environment variables. Per-account Telegram proxy configuration (channels.telegram.proxy) continues to use its own ProxyAgent via src/telegram/proxy.ts and is unaffected by this change.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change is a minimal, well-isolated fix that swaps one undici agent class for another with the same interface. EnvHttpProxyAgent is a drop-in replacement for Agent that adds proxy environment variable support without changing behavior when those variables aren't set. The fix is thoroughly tested with updated unit tests that verify the correct constructor is called, and all 527 existing Telegram tests pass. The change addresses a clear regression where users behind proxies lost connectivity after upgrading, while preserving the IPv6 fallback functionality introduced in the original PR.
  • No files require special attention

Last reviewed commit: d38520a

thebtf pushed a commit to thebtf/openclaw that referenced this pull request Feb 25, 2026
openclaw#25988

- openclaw#26229: replace Agent with EnvHttpProxyAgent in global undici dispatcher
  so HTTP_PROXY/HTTPS_PROXY env vars are respected for all outbound fetch
  calls (regression fix from openclaw#25682 that overwrote proxy-aware dispatcher)

- openclaw#26264: lower text fragment aggregation threshold 4000→3600 chars to
  reliably catch structured content that Telegram splits at ~3800 chars

- openclaw#25988: fail closed group allowlist against DM pairing store — group
  sender checks now use only explicit groupAllowFrom config, not the DM
  pairing store (security: DM-paired senders cannot bypass group allowlist)
@vincentkoc
Copy link
Member

I appreciate the early pass on this fix.

I’m closing this as a duplicate of #26239 because both changes address the same dispatcher/proxy regression in the same code path, and we need one canonical PR for merge flow.

Your earlier work is preserved in the canonical credit chain for this cluster.

If this boundary looks wrong, point me to the missing behavior and I’ll reopen review right away.

@vincentkoc vincentkoc closed this Feb 28, 2026
@vincentkoc vincentkoc added dedupe:child Duplicate issue/PR child in dedupe cluster close:duplicate Closed as duplicate labels Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram close:duplicate Closed as duplicate dedupe:child Duplicate issue/PR child in dedupe cluster size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 2026.2.24 regression — setGlobalDispatcher breaks HTTP proxy for all outbound requests

2 participants