#7611: fix: migrate channels.telegram.token to botToken on config load
Cluster:
Telegram Command Fixes
## What
When configuring Telegram, users often set token instead of the expected botToken. Previously, openclaw doctor would strip this as an "unrecognized key", causing data loss in the openclaw json (forcing manual edit). This PR adds a legacy migration to automatically rename token → botToken.
## Why
Improves UX by accepting the intuitive key name and auto-migrating it, rather than silently removing it.
## Changes
Added legacy rule to detect channels.telegram.token
Added migration for both top-level and per-account configs
Added tests for the migration
## Testing
[x] pnpm build ✅
[x] pnpm check ✅
[x] pnpm test ✅ (all 5222 tests pass)
AI-Assisted tho fully tested
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adds a legacy-config migration that renames `channels.telegram.token` (and `channels.telegram.accounts.*.token`) to `botToken` during config load, plus a legacy rule so `openclaw doctor` reports the deprecated key instead of silently stripping it. Tests were extended to cover both top-level and per-account migration behavior.
The change fits the existing config pipeline by extending the legacy detection rules (`src/config/legacy.rules.ts`) and adding an additional entry to the ordered legacy migration list (`src/config/legacy.migrations.part-3.ts`), which is composed into `LEGACY_CONFIG_MIGRATIONS` and applied on config load.
<h3>Confidence Score: 4/5</h3>
- This PR looks safe to merge and is unlikely to cause regressions.
- Changes are narrowly scoped to a legacy-config migration and detection rule, and the migration is guarded to avoid overwriting `botToken` when already present. The added tests cover the main migration paths; remaining feedback is mostly around log/test robustness rather than correctness.
- src/config/legacy.migrations.part-3.ts (migration change message formatting) and src/config/config.legacy-config-detection.rejects-routing-allowfrom.test.ts (test robustness/coverage).
<!-- 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
#11347: fix: scope Telegram update offset to bot token
by anooprdawar · 2026-02-07
82.2%
#11602: fix(config): skip stale legacy config files when openclaw.json exists
by akoscz · 2026-02-08
81.1%
#21029: Feature/telegram bot avatar clean
by aleonnet · 2026-02-19
78.2%
#14359: fix: prefer named Telegram account over orphan 'default' in binding...
by itsGustav · 2026-02-12
77.5%
#22363: fix(telegram): isolate update offset state by bot token
by AIflow-Labs · 2026-02-21
77.3%
#14488: Fix Telegram default account listing and CLI cache-write usage mapping
by abdulbb · 2026-02-12
77.1%
#16708: fix(security): OC-17 add token redaction to error formatting, depre...
by aether-ai-agent · 2026-02-15
76.4%
#5040: fix(config): migrate audio.transcription with any CLI command
by shayan919293 · 2026-01-31
76.2%
#21757: Docs/telegram inbound troubleshooting
by alanparesys · 2026-02-20
76.1%
#3561: fix: fail fast when both state dirs exist
by adityarao3 · 2026-01-28
76.1%