[Sources] Message links like https://t.me/channel/451 are accepted but fail to index #10

Closed
opened 2026-08-23 19:08:35 +02:00 by vmruiz · 1 comment
Owner

Current behaviour

The "Telegram chat" field in the Sources form (add-source dialog) accepts message links such as https://t.me/telegram/451 or https://t.me/somechannel/12345. These pass through _normalize_telegram_chat_identifier() unchanged because telethon.utils.parse_username does not recognise the t.me/<channel>/<message_id> shape (it returns (None, False)), so the value is stored verbatim as the Source.telegram_chat.

At indexing time, _resolve_chat() (app/telegram/indexer.py) calls client.get_entity("https://t.me/telegram/451"), which raises ValueError and the source never indexes.

Verified on current code:

>>> _normalize_telegram_chat_identifier("https://t.me/telegram/451")
"https://t.me/telegram/451"
>>> utils.parse_username("https://t.me/telegram/451")
(None, False)

So the message-link shape is neither normalised to a channel nor rejected - it silently becomes a source that can never be indexed.

Desired behaviour

Either:

  1. Reject message links at creation time with a clear error (e.g. "Telegram message links are not supported; use the channel link https://t.me/ or @username"), OR
  2. Accept and clean them - strip the trailing /<message_id> segment and keep only the channel part, so https://t.me/telegram/451 is stored as @telegram and indexes normally.

Option 2 is the more forgiving UX and reuses the existing normaliser, but it should be a deliberate choice. Either way, the stored value must always be a shape _resolve_chat understands (@username, numeric id, or t.me/+invite).

Introduced alongside the t.me link support in PR #9 / issue #4 - that only handled t.me/<username> channel links and t.me/+invite invite links, not t.me/<username>/<message_id> message links.

## Current behaviour The "Telegram chat" field in the Sources form (add-source dialog) accepts message links such as `https://t.me/telegram/451` or `https://t.me/somechannel/12345`. These pass through `_normalize_telegram_chat_identifier()` unchanged because `telethon.utils.parse_username` does not recognise the `t.me/<channel>/<message_id>` shape (it returns `(None, False)`), so the value is stored verbatim as the `Source.telegram_chat`. At indexing time, `_resolve_chat()` (app/telegram/indexer.py) calls `client.get_entity("https://t.me/telegram/451")`, which raises ValueError and the source never indexes. Verified on current code: ```python >>> _normalize_telegram_chat_identifier("https://t.me/telegram/451") "https://t.me/telegram/451" >>> utils.parse_username("https://t.me/telegram/451") (None, False) ``` So the message-link shape is neither normalised to a channel nor rejected - it silently becomes a source that can never be indexed. ## Desired behaviour Either: 1. Reject message links at creation time with a clear error (e.g. "Telegram message links are not supported; use the channel link https://t.me/<channel> or @username"), OR 2. Accept and clean them - strip the trailing /<message_id> segment and keep only the channel part, so `https://t.me/telegram/451` is stored as `@telegram` and indexes normally. Option 2 is the more forgiving UX and reuses the existing normaliser, but it should be a deliberate choice. Either way, the stored value must always be a shape `_resolve_chat` understands (@username, numeric id, or t.me/+invite). ## Related Introduced alongside the t.me link support in PR #9 / issue #4 - that only handled `t.me/<username>` channel links and `t.me/+invite` invite links, not `t.me/<username>/<message_id>` message links.

Branch preview deployed by CI.

Auto-generated by .forgejo/workflows/dev-deploy.yml.

Branch preview deployed by CI. - Branch: `fix/message-link-normalise` - Commit: `df887fbee0121bcd0d820cd34870d90b352a983d` - Endpoint: https://telegramarr-cb9f9f5d5.celor.es/ _Auto-generated by `.forgejo/workflows/dev-deploy.yml`._
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
vmruiz/telegramarr#10
No description provided.