Skip to content

connector-telegram: use teloxide-core instead of a hand-rolled client (decision needed) - #65

Open
radicalkjax wants to merge 1 commit into
mainfrom
connector-telegram/teloxide-core
Open

connector-telegram: use teloxide-core instead of a hand-rolled client (decision needed)#65
radicalkjax wants to merge 1 commit into
mainfrom
connector-telegram/teloxide-core

Conversation

@radicalkjax

Copy link
Copy Markdown
Member

What

Replaces the connector's hand-rolled Telegram Bot API client with teloxide-core 0.13 (rustls only), keeping the connector's API trait so the ten action modules and their mock tests are untouched; typed results are re-encoded to the trait's JSON shapes. Manual URL and token-path building, {ok,result}/retry_after parsing, and hand-built bodies are gone. Long polling keeps its offset/timeout/allowed_updates semantics on the SDK's getUpdates. Manifest, trigger and action names, output schemas, and the X-Telegram-Bot-Api-Secret-Token check are unchanged. The JSON update normaliser is kept: the SDK's Update is strict on kinds and would drop update types the pass-through tolerates. One incidental fix: the old error display could include the request URL, which carries the bot token; the SDK strips it.

Decision needed before merging

  • teloxide-core 0.13 pins reqwest 0.12, while the workspace is on reqwest 0.13, so the graph now has two reqwest and two rustls versions (0.23 and 0.26). The post-quantum hybrid key exchange the daemon installs for rustls 0.26 does not apply to Telegram traffic, which uses classical X25519 until the SDK moves to reqwest 0.13. safe_http's redirect cap also does not apply; timeouts were mirrored onto the SDK's settings.
  • The SDK holds the bot token as a plain Arc<str> with no zeroization.
  • cargo deny warns multiple-versions (policy is warn, not deny). takecell is pinned to 0.1.1 because 0.1.2 needs rustc 1.96 and the local toolchain is 1.94.1.

The GitHub migration (#51) had the smaller version of this trade-off (no redirect cap, but the same rustls stack and PQ provider). Here the loss is larger. Options: merge and accept classical key exchange for Telegram until teloxide catches up; or hold the branch until a teloxide-core release on reqwest 0.13 exists.

Verification

  • cargo clippy -p connector-telegram --all-targets -- -D warnings; cargo test -p connector-telegram: 68 passed
  • cargo tree -i native-tls, -i openssl-sys, -i hyper-tls: none; cargo deny check licenses bans: ok

Finding 88 (Telegram) in docs/ALIGNMENT-PLAN.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_018M415coMKAv5V2xJQsaSf8

… (plan 5.1)

Replace the hand-rolled reqwest client behind `TelegramApi` with
`teloxide_core::Bot`. The trait keeps its string-and-JSON signatures so
the ten action/polling call sites and every mock-client test are
untouched; the SDK's typed models are re-encoded to JSON at the boundary.

- teloxide-core 0.13 added as a workspace dep with `default-features =
  false, features = ["rustls"]`; `native-tls`, `openssl-sys`, `hyper-tls`
  absent from the connector graph. `url` added (SDK takes `url::Url`).
- Deleted: manual URL building (token in path), `{ok,result}` /
  `retry_after` parsing, hand-built JSON bodies, `TelegramError::Reqwest`.
  `RequestError::RetryAfter` maps to `RateLimited` so polling back-off is
  unchanged; teloxide strips the token from network errors before Display.
- Long polling uses the SDK's `getUpdates` with the same offset/timeout/
  allowed_updates semantics. Webhook secret-token check, manifest,
  trigger/action names and output schemas are unchanged; the JSON-based
  update normaliser is kept (as #51 did for GitHub).
- `takecell` pinned to 0.1.1 (0.1.2 needs rustc 1.96; toolchain is 1.94).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018M415coMKAv5V2xJQsaSf8
@radicalkjax

Copy link
Copy Markdown
Member Author

Upstream check: teloxide's main branch already depends on reqwest 0.13.3 (crates/teloxide-core/Cargo.toml), so the next teloxide-core release unifies the rustls stack and restores the post-quantum key exchange for Telegram traffic. Holding this PR until that release rather than merging a classical-KEX regression or pinning a git revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant