]> git.aero2k.de Git - urlbot-v3.git/commit
Fix NATS silently dropping messages whose routing key has an empty token master
authorThorsten <mail@aero2k.de>
Sat, 8 Aug 2026 09:58:51 +0000 (11:58 +0200)
committerThorsten <mail@aero2k.de>
Sat, 8 Aug 2026 09:58:51 +0000 (11:58 +0200)
commit85cb1b9feba6ea14499fc8b4367e06a89274d5dc
tree2b14ae3fcc3625308f77701c0d94bc3be985cd3b
parent473e7e897d721272b57f6d903aa81ff85720a5a9
Fix NATS silently dropping messages whose routing key has an empty token

bot.py joins shlex tokens with '.' and keeps any punctuation the body had,
so a message ending in a full stop ("<url> ... ich will das.") yields a
routing key ending in '.' - an empty trailing token. AMQP's topic exchange
routed that to '#' fine, but nats-server accepts the PUB without any error
while "classifier.>" never matches it, so the message vanished with nothing
logged on either side. Leading dots and a typed "..." (its own token) fail
the same way.

Collapse runs of dots and trim the ends in _sanitize_subject(), with a
fallback token for a key that reduces to nothing. Empty tokens carry no
information, and the binding keys plugins use still match the trimmed form.

Symptom that surfaced it: a posted YouTube URL followed by a sentence went
unanswered - and with URLResolver deliberately skipping youtube URLs, no
fallback title appeared either.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
src/distbot/common/broker_nats.py
tests/test_unit/test_broker_nats.py