Skip to content

fix: make can_react_to_messages optional in ChatMemberRestricted (closes #1812)#1839

Open
botbikamordehai2-sketch wants to merge 971 commits into
aiogram:masterfrom
botbikamordehai2-sketch:fix/issue-1812-1782302230
Open

fix: make can_react_to_messages optional in ChatMemberRestricted (closes #1812)#1839
botbikamordehai2-sketch wants to merge 971 commits into
aiogram:masterfrom
botbikamordehai2-sketch:fix/issue-1812-1782302230

Conversation

@botbikamordehai2-sketch

Copy link
Copy Markdown

What

Telegram API may omit can_react_to_messages field in ChatMemberRestricted, causing a Pydantic ValidationError when parsing updates. The field was defined as required bool.

Fix

Changed the field to bool | None = None to allow missing values.

Closes #1812

JrooTJunior and others added 30 commits November 18, 2023 21:28
* fix: CallbackData set optional as None

* docs: add fix changelog

* Add support for nullable fields in callback data

This update extends the callback data handling by adding support for nullable fields. The code now uses the Python typing structures `Optional` and `Union` to parse such fields correctly. A helper function `_check_field_is_nullable` has been added to assist in efficiently checking if a given field is nullable.

* Add support for nullable fields in callback data

This update extends the callback data handling by adding support for nullable fields. The code now uses the Python typing structures `Optional` and `Union` to parse such fields correctly. A helper function `_check_field_is_nullable` has been added to assist in efficiently checking if a given field is nullable.

---------

Co-authored-by: JRoot Junior <jroot.junior@gmail.com>
* Base implementation

* Small refactoring + added possibility to specify post-action on handlers

* Move scene properties to config object

* Revise aiogram/scenes with wizard-based design pattern

Modified files in aiogram/scenes to incorporate the Wizard design pattern. Files affected are _marker.py, _registry.py, _wizard.py and __init__.py. The changes introduced a SceneWizard Class and ScenesManager, both of which aid in controlling navigation between different scenes or states. This helps clarifying the codebase, streamline scene transitions and offer more control over the app flow.

* Added example

* Small optimizations

* Replace ValueError with SceneException in scenes. Added error safety in scene resolver.

* str

* Added possibility to reset context on scene entered and to handle callback query in any state

* Remove inline markup in example

* Small changes

* Docs + example

* Small refactoring

* Remove scene inclusion methods from router

The methods for including scenes as sub-routers have been removed from the router.py file. Instead, the SceneRegistry class is now set to register scenes by default upon initializing. This streamlines the scene management process by removing redundant routers and making registration automatic.

* Init tests

* Small fix in tests

* Add support for State instance in the scene

The aiogram FSM scene now allows the use of State instance as an argument, enabling more customization. Modified the 'as_handler' method to receive **kwargs arguments, allowing passing of attributes to the handler. An additional type check has been also added to ensure the 'scene' is either a subclass of Scene or a string.

* Fixed test

* Expand test coverage for test_fsm module

The commit enhances tests for the test_fsm module to improve code reliability. It includes additional unit tests for the ObserverDecorator and ActionContainer classes and introduces new tests for the SceneHandlerWrapper class. This ensures the correct functionality of the decorator methods, the action container execution, and the handler wrapper.

* Reformat code

* Fixed long line in the example

* Skip some tests on PyPy

* Change mock return_value

* Compatibility...

* Compatibility...

* Compatibility...

* Added base changes description

* Scenes Tests (aiogram#1369)

* ADD tests for `SceneRegistry`

* ADD tests for `ScenesManager`

* ADD Changelog

* Revert "ADD Changelog"

This reverts commit 6dd9301.

* Remove `@pytest.mark.asyncio`, Reformat code

* Scenes Tests. Part 2 (aiogram#1371)

* ADD tests for `SceneWizard`

* ADD tests for `Scene`

* Refactor ObserverDecorator to use on.message syntax in test_scene.py
Cover `Scene::__init_subclass__::if isinstance(value, ObserverDecorator):`

* Refactor `HistoryManager` in `aiogram/fsm/scene.py`
Removed condition that checked if 'history' is empty before calling 'update_data' in 'Scene'.

* ADD tests for `HistoryManager`

* Small changes in the documentation

* Small changes in the documentation

* Small changes in the documentation

---------

Co-authored-by: Andrew <11490628+andrew000@users.noreply.github.com>
* Update thumbnail type to InputFile only

The thumbnail's type restriction has been changed in several methods and types. Previously, it accepted Union[InputFile, str], allowing both InputFile instances and strings. Now it's changed to accept only InputFile instances. This change enhances meaning of the thumbnail fields in due to Bot API accepts only InputFile instances.

* Added changelog

* Fixed typehints
On line 576 corrected typo in world more (was mre)
* Added support for Bot API 7.0

* Fixed available tests

* Fixed text decorations

* Bot API 7.0 tests for ForwardMessages

* Bot API 7.0 tests for CopyMessages

* Bot API 7.0 tests for DeleteMessages

* Bot API 7.0 tests for GetUserChatBoosts

* Bot API 7.0 tests for SetMessageReaction

* Fixed custom_emoji attribute name

* Fixed tests

* Test parsing CallbackQuery message (inaccessible and accessible)

* Added changes description

* Bot API 7.0 tests for dispatcher handle update message_reaction

* Bot API 7.0 tests for dispatcher handle update message_reaction_count

* Bot API 7.0 tests for dispatcher handle update chat_boost

* Bot API 7.0 tests for dispatcher handle update removed_chat_boost

* fix tests: update ReactionTypeCustomEmoji custom_emoji -> custom_emoji_id

* micro fix Markdown V2 blockquote

* add tests for Markdown tools

* fix markdown test apply single entity

* add tests coverage for Message.react

* check that all messages and content types are covered for Message.content_type

* sort imports in tests (run `make reformat lint`)

* update Giveaway objects Unix time field to DateTime type

* Update Message.content_type property

* upgrade tests for message content_types and sent_copy

* Update Giveaway type generation config

* Update GiveawayWinners and PassportFile types generation configs

---------

Co-authored-by: Suren Khorenyan <surenkhorenyan@gmail.com>
* Reworked defaults

* Added changelog and partial docs
* Add KeyboardButtonPollTypeType enum

A new enum, KeyboardButtonPollType, has been added and documented. This enum holds types of polls that can be created and sent when the corresponding button is pressed. It is now imported and included in the aiogram enums documentation.

* Added changelog
aiogram#1399)

* Update KeyboardBuilder utility, fixed type-hints for button method, adjusted limits of the different markup types to real world values.

* Added changelog

* Fixed coverage

* Update aiogram/utils/keyboard.py

Co-authored-by: Suren Khorenyan <surenkhorenyan@gmail.com>

* Fixed codestyle

---------

Co-authored-by: Suren Khorenyan <surenkhorenyan@gmail.com>
…#1403)

* Update message.send_copy: add missing reply_parameters param

* added changes file

* update changes file

Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>

---------

Co-authored-by: Alex Root Junior <jroot.junior@gmail.com>
Three properties of the Bot class - parse_mode, disable_web_page_preview, and protect_content - have been marked as deprecated with proper warning messages. The associated tests have also been added to confirm the working of these deprecation warnings. Users are advised to use the updated alternatives specified in the warning messages.
JrooTJunior and others added 28 commits March 3, 2026 01:19
* Update API methods and types for Telegram Bot API 9.5

* Draft: follow-up for Bot API 9.5 (aiogram#1780) (aiogram#1781)

* Add set_chat_member_tag shortcut coverage

* Add set_member_tag shortcut tests and align decoration expectations

* Fix follow-up test coverage for sender_tag and can_edit_tag

* Add changelog fragment for PR 1781

* Align changelog with base PR aiogram#1780

* Expand 1780 changelog to cover base and follow-up scope

* Treat sender_tag as metadata, not message content type

---------

Co-authored-by: Latand <latand@users.noreply.github.com>
Co-authored-by: Codex Agent <codex@openclaw.local>

* Add tests for date_time formatting with Unix time and datetime objects

* Update changelog with Telegram Bot API 9.5 changes

---------

Co-authored-by: Kostiantyn Kriuchkov <36363097+Latand@users.noreply.github.com>
Co-authored-by: Latand <latand@users.noreply.github.com>
Co-authored-by: Codex Agent <codex@openclaw.local>
* fix UserWarning, model_custom_emoji_id

* Add changelog for aiogram#1772
Co-authored-by: unknown <nasrollahjusefi@gmail.com>
* Added full support for the Bot API 9.6

* Add support for `managed_bot` updates

* Set `description_parse_mode` default to `"parse_mode"` and use `DateTime` for `addition_date` in `PollOption`

* Update changelog with features and changes from Bot API 9.6

* Add changelog fragment generator and update poll parameter descriptions
* Add changelog for aiogram#1707

* Add __eq__ and __hash__ methods to the Default class

* Add tests for the eq and hash methods to the TestDefault
…iogram#1790)

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>
…alidation error message (aiogram#1788)

* Remove redundant list() around sorted()

* Fix type name in error message for router type validation

* Add changelog
Mirrors the existing reply_markup/message_effect_id fallback pattern:
explicit value wins, otherwise inherits from the source message.
Only applied to the SendMessage branch - other copy targets don't
accept link_preview_options.

Closes aiogram#1620
…cstrings (aiogram#1796)

* improve grammar in MemoryStorage, PyMongoStorage, and RedisStorage docstrings

* add the changelog rst for aiogram#1796
)

* Bump pydantic (`<2.13` -> `<2.14`) and other dev/test deps

* Add changelog fragment for aiogram#1795

* Fix `PLW0108 Lambda may be unnecessary; consider inlining inner function`

* Calm down MyPy

* Reformat
* Added full support for the Bot API 10.0

* Fixed tests

* Add tests for Bot API 10.0 methods

* Added changelog

* Add support for `guest_message` event

* Update localization files with new translations and metadata adjustments

* Add `answer_guest_query` method shortcut
…am#1809)

* Fix link formatting for pydantic in migration docs (aiogram#1624)

* Add `InputPollOptionMediaUnion` type alias and update media classes for poll options to fix sending poll options with media

* Update changelog for `InputPollOptionMediaUnion` fix and media class adjustments

---------

Co-authored-by: Сода <93333363+Soda-Na@users.noreply.github.com>
…utMedia*` types

(cherry picked from commit 1457d36)
* Added support of the Bot API 10.1

* Add tests for rich messages, chat join requests, and related methods

* Clean dots

* Expand rich messages and chat join request functionality, adding new methods, shortcuts, and tests

* Improve handling of `query_id` in chat join requests and update related tests and aliases

* Expand rich message capabilities and chat join request features as per Bot API 10.1, adding new methods, types, fields, and breaking changes

* Add `RichBlockType` and `RichTextType` enums, refactor rich text and block types to use enums instead of literal strings, and update related docs and imports

* Re-apply API changes

* Remove redundant note about `text` positional argument in breaking changes
@github-actions

Copy link
Copy Markdown

✔️ Changelog found.

Thank you for adding a description of the changes

@andrew000

Copy link
Copy Markdown
Contributor

Change target branch to dev-3.x

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.