Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 736ec7d

Browse files
Watchful1claude
andcommitted
Fall back to comment id when permalink is unavailable
PRAW inbox Comments don't reliably include permalink in their lazy payload, which was crashing the mention-detection log line. Catch the AttributeError and substitute a comment-id string so the warning fires cleanly. Co-Authored-By: Claude Opus 4.7 <[email protected]>
1 parent a7ad529 commit 736ec7d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/messages.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,10 @@ def process_messages(reddit, database):
370370
has_command = comments.body_contains_command(message.body)
371371
mention_type = 'with_command' if has_command else 'mention_only'
372372
counters.mentions.labels(type=mention_type).inc()
373-
permalink = utils.reddit_link(message.permalink)
373+
try:
374+
permalink = utils.reddit_link(message.permalink)
375+
except AttributeError:
376+
permalink = f"comment {message.id}"
374377
if static.MENTION_DETECTION_WARN:
375378
log.warning(f"Username mention from u/{utils.author_name(message.author)}: {message.id} : {permalink}")
376379
else:

0 commit comments

Comments
 (0)