Skip to content

A command with a bare «@» is a command to aiogram but not to the form breakout, so a form step takes it as its answer #276

Closed

Description

@lumenpearson

CommandBreakoutMiddleware (app/bot/middlewares.py) drops a half-finished form when the message is a command, so that a command typed at a free-text step runs instead of becoming the step's answer. It decides what a command is with _COMMAND = ^/[A-Za-z0-9_]+(@[A-Za-z0-9_]+)?(\s|$) (line 47). aiogram's Command filter decides differently: it accepts a command with an empty mention.

Checked on 3 October 2026 in the server's venv:

Command('homework').extract_command('/homework@')  -> command 'homework', mention None
looks_like_command('/homework@')                   -> False

So /week@ (or any command followed by a bare @) is a command to the handlers but not to the breakout.

Failure scenario. An editor is at «Теперь пришлите текст задания:» and types /week@ — a slip of the keyboard, or a client that leaves the @ after deleting the bot's name. The middleware does not see a command, the form stays open, and the step, which filters on state alone and is registered before week, takes «/week@» as the assignment's text: committed, audited and announced to the class — the very defect the middleware's docstring describes, through a gap of one character.

Found while planning the server decomposition (sub-project 1 of docs/specs/2026-10-03-one-contract-design.md), which keeps the homework ticks' place in the dispatch order because of it. Not fixed there. The fix is to make looks_like_command agree with aiogram's parsing (accept an empty mention), with a test that sends /week@ at an open form.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions