Files
odysseus/routes
Robert Vind-GardoșandAlexandre Teixeira c23b1be3f8 fix(history): reject implicit and coerced truncation targets (#6565)
* fix(history): reject implicit and coerced truncation targets

* fix(history): reject falsy non-string message IDs; drop redundant keep_count guard

The or-chain used to resolve before_msg_id / message_id evaluated
falsy non-strings (False, 0) to '' before the isinstance(…, str) check
was reached, so they silently bypassed type validation.  Replace the
chain with explicit presence-aware logic that falls through on None or
empty string (preserving alias semantics) but rejects any other
non-string value with HTTP 400.

Also remove the now-tautological 'if keep_count >= 0:' guard, which
is always True after the negativity check introduced in the parent
commit.  The DB block is unconditional and indented accordingly.

Tests: add {'before_msg_id': False}, {'before_msg_id': 0},
{'message_id': 0} to the parametrised rejection suite.

36 passed, 0 failed (Python 3.14.4 / pytest 9.1.1).

---------

Co-authored-by: Alexandre Teixeira <111787685+alteixeira20@users.noreply.github.com>
2026-10-14 08:41:38 +01:00
..
2026-09-11 06:04:19 +00:00
2026-05-31 23:58:26 +09:00
2026-05-31 23:58:26 +09:00