Skip to content

fix: CommandStart(deep_link=False) now rejects deep-link arguments#1790

Merged
JrooTJunior merged 1 commit into
aiogram:dev-3.xfrom
temrjan:fix/command-start-deep-link-false
Apr 3, 2026
Merged

fix: CommandStart(deep_link=False) now rejects deep-link arguments#1790
JrooTJunior merged 1 commit into
aiogram:dev-3.xfrom
temrjan:fix/command-start-deep-link-false

Conversation

@temrjan

@temrjan temrjan commented Mar 24, 2026

Copy link
Copy Markdown

Summary

Closes #1713

CommandStart(deep_link=False) now correctly matches only /start without arguments, rejecting /start <payload>.

Problem

The deep_link parameter had only two effective states:

  • False (default) — accepted any /start command, with or without arguments
  • True — required arguments to be present

There was no way to say "match only if there is no deep-link payload."

Solution

Change deep_link to a three-state parameter (None | bool):

Value Behavior Backward compatible?
None (new default) Accept any /start Yes — same as old False default
True Require deep-link args Yes — unchanged
False Reject deep-link args New — fixes the bug

Test plan

  • 56/56 tests pass in tests/test_filters/test_command.py
  • Added test: /start + CommandStart(deep_link=False) → True
  • Added test: /start test + CommandStart(deep_link=False) → False
  • Added test: /start + CommandStart() → True (backward compat)
  • Changelog fragment: CHANGES/1713.bugfix.rst

🤖 Generated with Claude Code

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>
@github-actions github-actions Bot added the 3.x Issue or PR for stable 3.x version label Mar 24, 2026
@github-actions

Copy link
Copy Markdown

✔️ Changelog found.

Thank you for adding a description of the changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_link from bool to bool | None with None as 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

codecov Bot commented Apr 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (49eac31) to head (79f92af).
⚠️ Report is 6 commits behind head on dev-3.x.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##           dev-3.x     #1790   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          607       607           
  Lines        14425     14430    +5     
=========================================
+ Hits         14425     14430    +5     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
aiogram/filters/command.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JrooTJunior JrooTJunior merged commit 0611d0d into aiogram:dev-3.x Apr 3, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.x Issue or PR for stable 3.x version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CommandStart ignore deep_link=False

3 participants