Bug Description
create_deep_linked_url validates bot_username with len(bot_username) <= 3, which means 4-character usernames are accepted without error.
However, the Telegram Bot documentation explicitly states:
Usernames are 5-32 characters long and not case sensitive – but may only include Latin characters, numbers, and underscores.
Steps to Reproduce
from telegram.helpers import create_deep_linked_url
# Should raise ValueError (4 chars < 5 minimum) but doesn't:
url = create_deep_linked_url("xbot", "payload")
print(url) # https://t.me/xbot?start=payload ← silently wrong
Expected behaviour
create_deep_linked_url("xbot", "payload") should raise ValueError because "xbot" is only 4 characters, below Telegram's 5-character minimum.
Actual behaviour
No error is raised; the function returns a URL with an invalid username.
Root Cause
In src/telegram/helpers.py the guard is:
if bot_username is None or len(bot_username) <= 3:
raise ValueError("You must provide a valid bot_username.")
The condition should be len(bot_username) < 5 (i.e., <= 4) to match Telegram's actual minimum of 5 characters.
The docstring also incorrectly states "less than 4 characters" instead of "less than 5 characters".
Operating System
Any
Version of Python, python-telegram-bot & dependencies
Any
Relevant log output
N/A
Bug Description
create_deep_linked_urlvalidatesbot_usernamewithlen(bot_username) <= 3, which means 4-character usernames are accepted without error.However, the Telegram Bot documentation explicitly states:
Steps to Reproduce
Expected behaviour
create_deep_linked_url("xbot", "payload")should raiseValueErrorbecause"xbot"is only 4 characters, below Telegram's 5-character minimum.Actual behaviour
No error is raised; the function returns a URL with an invalid username.
Root Cause
In
src/telegram/helpers.pythe guard is:The condition should be
len(bot_username) < 5(i.e.,<= 4) to match Telegram's actual minimum of 5 characters.The docstring also incorrectly states "less than 4 characters" instead of "less than 5 characters".
Operating System
Any
Version of Python, python-telegram-bot & dependencies
Any
Relevant log output
N/A