oliver-zehentleitner / maity

hub tests: test_product_line now and then misses the dead sign-in mail in the outbox on SQLite

Sign in to report

tsk-knmx8yw3s1xa Done Maity Coder Claude 002

Flake seen on #1717 (hub-sqlite): a tests/test_product_line.py test expected the dead sign-in mail in the outbox and did not find it. Re-run alone, it was green. It is not related to #1717's change. Reported by maity-review-team-lead#vuur.

Not diagnosed yet.

Wanted:

  1. Find the cause (ordering, a shared outbox between tests, timing of the mail write, or something else) and make the test deterministic.
  2. If the cause is in the hub rather than the test, say so on the card before fixing.

Separate from the with_postgres.sh trap card.

Notes

  1. Maity Coder Claude 002 · Nov 13, 2026, 11:02 UTC

    Cause (reproduced; in the tests, not in the hub). routes/email_sign_in.LIMITS is the hub's in-process limiter for POST /auth/email-link: per source and address, 3 requests per 15 minutes (past that the answer stays 202 and no mail is written, as §2.6.4 wants). On SQLite and MariaDB it counts in the test process. hub/tests/conftest.py's reset block (_fresh_process_state) never resets it; only tests/test_email_sign_in.py swaps in a fresh one through its own autouse limits fixture. routes/password_reset.LIMITS is the same gap.

    Four tests outside that file ask for a link for ada@example.com from the test client: test_mail_factor.py:621, test_password_reset.py:265, test_product_line.py:316, test_product_line.py:343. When all four land on one xdist worker within 15 minutes, the fourth gets 202 and no mail, so mail() fails with assert row is not None (tests/test_email_sign_in.py:65). Which worker gets which test varies by run, hence the flake.

    Evidence (one process, -p no:randomly, origin/main a0ffad500fbbbe62278627458d93a1d0bf508ed1):

    • A test_mail_factor.py::test_under_email_the_sign_in_link_is_off_and_answers_as_if_sent, B test_password_reset.py::test_complete_sets_the_password_ends_everything_and_signs_nobody_in, C test_product_line.py::test_the_sign_in_link_page_stands_in_the_frame_in_the_humans_language, D test_product_line.py::test_the_dead_sign_in_link_stands_in_the_frame_in_the_browsers_language
    • A B C D: 1 failed (D, assert None is not None), 3 passed
    • D alone: 1 passed; B C D: 3 passed
    • Seen in CI on #1717 and #1723 (run 43405647189).

    Fix: the conftest reset block resets these limiters per test, and I am checking the rest of the hub's in-process limiters for the same gap. PR follows.

  2. Maity Coder Claude 002 · Nov 13, 2026, 12:10 UTC

    PR #1727: https://github.com/oliver-zehentleitner/maity/pull/1727 (head e9475e0537687ce8c9e384d4859935af5b21e64a, base a0ffad500fbbbe62278627458d93a1d0bf508ed1). Only tests change.

    _fresh_process_state in hub/tests/conftest.py now resets every Limiter that a hub module holds, either as a module attribute or one attribute further down (RequestLimits). The helper process_limiters() finds them, so there is no hand-kept list. It finds 44 limiters in about 1.7 ms. The old list missed 24 of them: the six inside email_sign_in.LIMITS and password_reset.LIMITS, plus 18 others (attachments, mail_factor, second_factor_reset, avatars, contacts, cross_chats, invitations, presence, forge_webhook ×3, registration ×4, ticker ×2).

    This deviates from the plan of adding two entries to the list. With 24 missing, the next new limiter would leak again. Keep the Why 4debb183-43cc-4ae5-8730-d2b4e8e03fc5 records why.

    Red/green in one process: A B C D on origin/main: 1 failed, 3 passed. On the branch: 4 passed. Full hub suite -n 2: 6883 passed, 158 skipped.