fix: replace decorator misuse with MaintenanceAwareTree subclass (#82) #84
No reviewers
Labels
No Label
ai-changes-requested
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
in-next-release
status/in-progress
status/pr-open
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-v2#84
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "ai/major-domo-v2-82"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #82
Problem
setup_hookused@self.tree.interaction_checkas a decorator, butCommandTree.interaction_checkis an async method meant to be overridden via subclassing — not a decorator factory. Python was calling the coroutine with the decorated function as its argument, producing aRuntimeWarning: coroutine 'CommandTree.interaction_check' was never awaitedand leaving maintenance mode as a complete no-op.Fix
MaintenanceAwareTree(discord.app_commands.CommandTree)subclass beforeSBABotthat overridesinteraction_checkwith the maintenance check logictree_cls=MaintenanceAwareTreetosuper().__init__inSBABot.__init__@self.tree.interaction_checkdecorator block fromsetup_hookThe
interaction_checkoverride accessesbot.maintenance_modeviainteraction.client, which is the standard pattern for tree-level checks that need bot state.Files Changed
bot.py— newMaintenanceAwareTreeclass,tree_clskwarg, removed decorator blockTest Results
945 passed, 2 skipped
AI Code Review
Files Reviewed
bot.py(modified)Findings
Correctness
mergeable: false. Branchai/major-domo-v2-82was cut from commit0a2df0f(PR #81), before PR #83 (fix/maintenance-mode-interaction-check) landed onmain. PR #83 already added theMaintenanceAwareTreeclass andtree_cls=MaintenanceAwareTreetomain, creating a direct conflict with the identical additions in this PR.MaintenanceAwareTreeclass definition (lines 67–103 in currentmain) and thetree_cls=MaintenanceAwareTreekwarg (line 118) already exist. Merging as-is would produce a duplicate class at module scope.getattr(bot, "maintenance_mode", False)is the right safe-access pattern forinteraction.client, the admin permission check is sound, and the ephemeral response is appropriate.Security
Style & Conventions
# type: ignore[assignment]onbot = interaction.clientis correct —interaction.clientis typed asdiscord.Client, narrowing toSBABotrequires the ignore.CommandTreesubclassing pattern.Suggestions
main, the only change needed is removing the stale@self.tree.interaction_checkdecorator block fromsetup_hook(lines 129–143 in currentmain). The class addition andtree_clskwarg are already in place — this becomes a one-hunk, ~16-line removal.main(not introduced by this PR):self.maintenance_mode: bool = Falseis assigned twice inSBABot.__init__(lines 121 and 123) — apparent merge artifact from PR #83. Worth a follow-up cleanup commit.Verdict: REQUEST_CHANGES
The fix is conceptually correct and the logic is sound, but the PR cannot be merged in its current state (
mergeable: false). Rebaseai/major-domo-v2-82on currentmain, resolve the conflict (drop theMaintenanceAwareTreeclass addition since it's already present), and the result should be a clean removal of the dead decorator block that merges immediately.Automated review by Claude PR Reviewer
Pull request closed