Skip to content

Fix create_deep_linked_url accepting 4-character bot usernames - #5325

Open
Sanjays2402 wants to merge 1 commit into
python-telegram-bot:masterfrom
Sanjays2402:fix/deep-linked-url-min-username-length
Open

Fix create_deep_linked_url accepting 4-character bot usernames#5325
Sanjays2402 wants to merge 1 commit into
python-telegram-bot:masterfrom
Sanjays2402:fix/deep-linked-url-min-username-length

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #5284

create_deep_linked_url guarded bot_username with len(bot_username) <= 3, so a 4-character username was accepted and produced a URL Telegram cannot resolve; Telegram requires usernames to be 5-32 characters. The guard now rejects anything under 5 characters, and the docstring states the correct minimum.

Per @harshil21's review on the earlier #5285, I kept a single test: the existing too-short-username assertion in tests/test_helpers.py now uses a 4-character name. It fails without the source change (DID NOT RAISE ValueError) and passes with it; tests/test_helpers.py is 183 passed, ruff check and format clean.

I did not add the changes/unreleased/*.toml chango fragment — happy to push it, or it can be added with the suggested wording: bugfixes = "Fixed ``create_deep_linked_url`` silently accepting 4-character bot usernames".

This change was prepared with AI assistance; the regression test was run locally and fails without the fix.

create_deep_linked_url validated bot_username with len(bot_username) <= 3,
so a 4-character username was accepted and produced a URL Telegram cannot
resolve. Telegram requires usernames to be 5-32 characters, so the guard
now rejects anything shorter than 5 characters and the docstring states
the correct minimum.

Updated the existing too-short-username assertion in
tests/test_helpers.py to use a 4-character name, which fails without the
fix and passes with it.

Closes python-telegram-bot#5284
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.

create_deep_linked_url accepts 4-character bot usernames, but Telegram requires a minimum of 5

1 participant