fix: CommandStart(deep_link=False) now rejects deep-link arguments#1790
Conversation
Previously the deep_link parameter only had two effective states: False (default) accepted any /start command regardless of arguments, and True required arguments to be present. Change the default to None (accept both, backward compatible) so that False can mean "reject if deep-link arguments are present", which is the intuitive expectation when explicitly passing deep_link=False. Closes aiogram#1713 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
✔️ Changelog found.Thank you for adding a description of the changes |
There was a problem hiding this comment.
Pull request overview
Updates CommandStart to support a tri-state deep_link option so callers can explicitly reject /start commands that include a payload, while keeping the default behavior backward-compatible (accept /start with or without args).
Changes:
- Change
CommandStart.deep_linkfrombooltobool | NonewithNoneas the new default (accept any/start). - Implement explicit rejection of deep-link args when
deep_link=False. - Add/adjust tests and a Towncrier changelog fragment for the new behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
aiogram/filters/command.py |
Implements tri-state deep_link logic and enforces “no args” when deep_link=False. |
tests/test_filters/test_command.py |
Adds coverage for /start with/without args across CommandStart() and CommandStart(deep_link=False), and updates __str__ expectation. |
CHANGES/1713.bugfix.rst |
Documents the behavior change and the backward-compatible default shift to None. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev-3.x #1790 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 607 607
Lines 14425 14430 +5
=========================================
+ Hits 14425 14430 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Summary
Closes #1713
CommandStart(deep_link=False)now correctly matches only/startwithout arguments, rejecting/start <payload>.Problem
The
deep_linkparameter had only two effective states:False(default) — accepted any/startcommand, with or without argumentsTrue— required arguments to be presentThere was no way to say "match only if there is no deep-link payload."
Solution
Change
deep_linkto a three-state parameter (None | bool):None(new default)/startFalsedefaultTrueFalseTest plan
tests/test_filters/test_command.py/start+CommandStart(deep_link=False)→ True/start test+CommandStart(deep_link=False)→ False/start+CommandStart()→ True (backward compat)CHANGES/1713.bugfix.rst🤖 Generated with Claude Code