fix(gateway): keep no-patterns early return in mention compilation

The compile_mention_patterns promotion moved the 'patterns is None ->
return []' short-circuit into the shared helper, which meant the
telegram/dingtalk wrappers now evaluated self.name (via log_prefix=)
even on the no-patterns path. On main that path returned before
touching any adapter attributes; tests construct bare adapters via
object.__new__ that lack .platform, so TestTelegramGuestMentionGating
failed with AttributeError. Restore the early return in both wrappers
for exact behavior parity with main.
This commit is contained in:
teknium1 2026-07-29 10:57:55 -07:00 committed by Teknium
parent 1f45ff9e8a
commit 703fe94174
2 changed files with 12 additions and 0 deletions

View File

@ -458,6 +458,12 @@ class DingTalkAdapter(BasePlatformAdapter):
loaded = [part.strip() for part in raw.split(",") if part.strip()]
patterns = loaded
if patterns is None:
# Parity with the historical inline implementation: return before
# evaluating ``self.name`` (avoids touching adapter attributes on
# the no-patterns path).
return []
return compile_mention_patterns(
patterns,
log_prefix=self.name,

View File

@ -7818,6 +7818,12 @@ class TelegramAdapter(BasePlatformAdapter):
loaded = [part.strip() for part in raw.split(",") if part.strip()]
patterns = loaded
if patterns is None:
# Parity with the historical inline implementation: return before
# evaluating ``self.name`` (tests construct bare adapters via
# object.__new__ that lack the attributes ``name`` reads).
return []
return compile_mention_patterns(
patterns,
log_prefix=self.name,