Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from bundle
Use when building or fixing aiogram 3 bots that need aiogram_i18n with Fluent/FTL, topic-aware reply handling, Telegram quote and forward-origin context, and pr
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/middleware-order.md
1# Middleware Order23Middleware order is a product decision, not just a wiring detail.45A neutral production sequence is:61. observability72. concurrency control83. database or storage session setup94. idempotency105. tenant or chat resolution116. user loading127. i18n setup138. incoming message persistence149. command or feature permissions1510. business rules specific to the bot1611. post-processing side effects1718Why this order works:19- observability wraps everything20- idempotency and throttling happen before expensive business logic21- i18n is available before handlers start rendering22- persistence runs before downstream consumers depend on canonical message data23- feature-specific checks happen after core context is already loaded2425Use separate middleware stacks for:26- `message`27- `edited_message`28- `callback_query`2930Do not assume the same middleware set is correct for all update types.31