#23297: Telegram: force curl transport and typing fix
channel: telegram
size: M
Cluster:
Messaging Platform Improvements
## Summary
Describe the problem and fix in 2–5 bullets:
- Problem:
- Why it matters:
- What changed:
- What did NOT change (scope boundary):
## Change Type (select all)
- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Docs
- [ ] Security hardening
- [ ] Chore/infra
## Scope (select all touched areas)
- [ ] Gateway / orchestration
- [ ] Skills / tool execution
- [ ] Auth / tokens
- [ ] Memory / storage
- [ ] Integrations
- [ ] API / contracts
- [ ] UI / DX
- [ ] CI/CD / infra
## Linked Issue/PR
- Closes #
- Related #
## User-visible / Behavior Changes
List user-visible changes (including defaults/config).
If none, write `None`.
## Security Impact (required)
- New permissions/capabilities? (`Yes/No`)
- Secrets/tokens handling changed? (`Yes/No`)
- New/changed network calls? (`Yes/No`)
- Command/tool execution surface changed? (`Yes/No`)
- Data access scope changed? (`Yes/No`)
- If any `Yes`, explain risk + mitigation:
## Repro + Verification
### Environment
- OS:
- Runtime/container:
- Model/provider:
- Integration/channel (if any):
- Relevant config (redacted):
### Steps
1.
2.
3.
### Expected
-
### Actual
-
## Evidence
Attach at least one:
- [ ] Failing test/log before + passing after
- [ ] Trace/log snippets
- [ ] Screenshot/recording
- [ ] Perf numbers (if relevant)
## Human Verification (required)
What you personally verified (not just CI), and how:
- Verified scenarios:
- Edge cases checked:
- What you did **not** verify:
## Compatibility / Migration
- Backward compatible? (`Yes/No`)
- Config/env changes? (`Yes/No`)
- Migration needed? (`Yes/No`)
- If yes, exact upgrade steps:
## Failure Recovery (if this breaks)
- How to disable/revert this change quickly:
- Files/config to restore:
- Known bad symptoms reviewers should watch for:
## Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write `None`.
- Risk:
- Mitigation:
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds a new curl-based HTTP transport option for Telegram API calls and fixes typing issues in the curl fetch implementation.
**Changes:**
- Added `forceCurl` configuration option to `TelegramNetworkConfig` (config schema, types, labels, help text)
- Implemented `createTelegramCurlFetch` in `src/telegram/curl-fetch.ts` that spawns curl subprocess for HTTP requests
- Added `resolveTelegramForceCurlDecision` to handle env vars (`OPENCLAW_TELEGRAM_FORCE_CURL`, `OPENCLAW_TELEGRAM_DISABLE_CURL`) and config
- Updated `send.ts` to use curl transport when `forceCurl` is enabled
- Fixed Response body typing in curl-fetch (changed from passing `Uint8Array` directly to wrapping in `Blob`)
- Simplified body handling by using `request.arrayBuffer()` instead of manual body type normalization
- Added comprehensive tests for forceCurl config resolution and integration
**Why this matters:**
- Provides alternative transport for environments where Node.js fetch may have issues
- Allows bypassing Node's HTTP stack entirely for Telegram API calls
- Useful for debugging network issues or working around runtime-specific bugs
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The changes are well-structured with proper configuration handling, comprehensive tests, and clean separation of concerns. The typing fix simplifies the code and resolves build issues. The curl transport is an optional feature that defaults to disabled, minimizing impact on existing functionality.
- No files require special attention
<sub>Last reviewed commit: be1c9ed</sub>
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#19213: Telegram: preserve DM topic thread in direct replies
by Kemalau · 2026-02-17
77.2%
#22434: feat(telegram): support sending original quality images
by godenjan · 2026-02-21
76.7%
#3174: Telegram: restore types after removing ts-nocheck
by yashgo0018 · 2026-01-28
76.5%
#21898: fix(telegram): auto-detect captionable messages for editMessageCaption
by ptrkstr · 2026-02-20
75.5%
#7247: fix(telegram): abort stale getUpdates connections after long-poll t...
by JanderV · 2026-02-02
75.0%
#21757: Docs/telegram inbound troubleshooting
by alanparesys · 2026-02-20
74.9%
#19673: fix(telegram): avoid starting streaming replies with only 1-2 words
by emanuelst · 2026-02-18
74.8%
#12870: fix: recover from telegram fetch errors (issue #12835)
by ambicuity · 2026-02-09
74.7%
#7141: fix(telegram): unify network error detection to prevent poll crashes
by hclsys · 2026-02-02
74.4%
#19399: telegram: fix MEDIA false positives and partial final drop
by HOYALIM · 2026-02-17
74.4%