Skip to content

Fix AttributeError in maybe_archive_idle_post when post is missing#3498

Merged
wookie184 merged 2 commits intopython-discord:mainfrom
oliveman-au:fix/help-channel-attributeerror-on-missing-post
May 4, 2026
Merged

Fix AttributeError in maybe_archive_idle_post when post is missing#3498
wookie184 merged 2 commits intopython-discord:mainfrom
oliveman-au:fix/help-channel-attributeerror-on-missing-post

Conversation

@oliveman-au
Copy link
Copy Markdown
Contributor

When get_or_fetch_channel raises discord.HTTPException, the except block references post and post.id — but post was never assigned since the exception occurred before the assignment completed. This causes an AttributeError: 'int' object has no attribute 'id', meaning the error handler itself crashes instead of recovering gracefully.

Fixed by replacing post and post.id with post_id in the log line, which is the integer that was passed into the function.

@L3viathan
Copy link
Copy Markdown
Contributor

LGTM

Copy link
Copy Markdown
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find, thanks for the PR 🚀

I checked and confirmed that this is a bug that was being triggered in production, created+linked a sentry issue just for added context.

@wookie184 wookie184 enabled auto-merge May 4, 2026 09:36
@wookie184 wookie184 merged commit 0c2b96f into python-discord:main May 4, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnboundLocalError: cannot access local variable 'post' where it is not associated with a value

4 participants