#21992: fix(telegram): allow colon in provider name for model callback parsing (#21939)
docs
channel: telegram
size: XS
experienced-contributor
Cluster:
Session Management Enhancements
## Summary
- **Bug**: Clicking a provider with `:` in its name (e.g. `ollama:cloud`) in Telegram `/models` inline keyboard triggers a new LLM run instead of showing the model list
- **Root cause**: `parseModelCallbackData` regex `[a-z0-9_-]` excludes `:`, so callback data like `mdl_list_ollama:cloud_1` never matches
- **Fix**: Add `:` to the regex character class
Fixes #21939
## Problem
The `parseModelCallbackData` function in `src/telegram/model-buttons.ts` uses this regex to parse list callbacks:
```typescript
const listMatch = trimmed.match(/^mdl_list_([a-z0-9_-]+)_(\d+)$/i);
```
The character class `[a-z0-9_-]` does not include `:`. Providers like `ollama:cloud` generate callback data `mdl_list_ollama:cloud_1` which fails to match. The function returns `null`, causing the callback to fall through to the catch-all handler that creates a synthetic text message and triggers a new LLM agent run on every button click.
**Before fix:**
Input: `"mdl_list_ollama:cloud_1"`
Output: `null`
## Changes
- `src/telegram/model-buttons.ts` — add `:` to regex character class: `[a-z0-9_:-]`
- `src/telegram/model-buttons.test.ts` — add regression test for colon in provider name
**After fix:**
Input: `"mdl_list_ollama:cloud_1"`
Output: `{ type: "list", provider: "ollama:cloud", page: 1 }`
## Test plan
- [x] New test: colon in provider name parses correctly
- [x] All existing model-buttons tests pass
- [x] Lint passes
## Effect on User Experience
**Before:** Clicking a provider like `ollama:cloud` in the Telegram `/models` inline keyboard triggers an endless loop of new LLM runs instead of showing the model list.
**After:** Clicking any provider (including those with colons) correctly shows the paginated model list.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixed regex parsing for Telegram inline keyboard callbacks to allow colons in provider names (e.g., `ollama:cloud`). The character class in `parseModelCallbackData` was expanded from `[a-z0-9_-]` to `[a-z0-9_:-]` on line 51 of `src/telegram/model-buttons.ts`.
- **Root cause**: Provider names containing `:` like `ollama:cloud` generated callback data `mdl_list_ollama:cloud_1` that failed to match the regex, causing the parser to return `null` and triggering spurious LLM runs
- **Fix**: Added `:` to the allowed character class in the list callback regex pattern
- **Test coverage**: New regression test added for colon-containing provider names
- **Impact**: Providers with colons now correctly display model lists instead of triggering unintended agent runs
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The fix is a precise, minimal change to a regex character class with comprehensive test coverage. The change is backward-compatible (still matches all previous valid provider names), fixes a real bug with a clear reproduction path, and includes a regression test. The affected code is well-isolated to the parsing function with no side effects.
- No files require special attention
<sub>Last reviewed commit: 01d5aaf</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22025: fix(telegram): accept colon provider ids in mdl_list callbacks
by lc708 · 2026-02-20
92.1%
#20136: Telegram: fix cross-provider model checkmark in /models keyboard
by powerdot · 2026-02-18
80.1%
#21998: fix(models): prioritize exact model-id match over fuzzy scoring (#2...
by lailoo · 2026-02-20
76.1%
#11198: fix(models): strip @profile suffix from model selection
by mcaxtr · 2026-02-07
73.7%
#3496: fix(tui): handle /model status and /model list subcommands
by zerone0x · 2026-01-28
72.4%
#9905: fix: require provider prefix for models set without alias (#5790)
by petter-b · 2026-02-05
72.3%
#23136: fix: lookupContextTokens should handle provider/model refs
by patchguardio · 2026-02-22
71.3%
#18587: fix(ollama): improve timeout handling and cooldown logic for local ...
by manthis · 2026-02-16
71.2%
#20204: fix(sessions): allow negative IDs and colon separators in session IDs
by zerone0x · 2026-02-18
70.7%
#6673: fix: preserve allowAny flag in createModelSelectionState for custom...
by tenor0 · 2026-02-01
70.6%