From 7f856ee003a958e0b0a49893eb58a88fdff8ff66 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Tue, 3 Mar 2026 12:04:48 -0600 Subject: [PATCH] =?UTF-8?q?store:=20PR=20review:=20major-domo-v2#62=20?= =?UTF-8?q?=E2=80=94=20maintenance=20mode=20flag=20(REQUEST=5FCHANGES)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...intenance-mode-flag-request-chan-729df2.md | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 graph/workflows/pr-review-major-domo-v262-maintenance-mode-flag-request-chan-729df2.md diff --git a/graph/workflows/pr-review-major-domo-v262-maintenance-mode-flag-request-chan-729df2.md b/graph/workflows/pr-review-major-domo-v262-maintenance-mode-flag-request-chan-729df2.md new file mode 100644 index 00000000000..b56898b0c49 --- /dev/null +++ b/graph/workflows/pr-review-major-domo-v262-maintenance-mode-flag-request-chan-729df2.md @@ -0,0 +1,42 @@ +--- +id: 729df25e-abb1-4b3a-afe5-1f2b5fb8cd50 +type: workflow +title: "PR review: major-domo-v2#62 — maintenance mode flag (REQUEST_CHANGES)" +tags: [pr-reviewer, major-domo-v2, discord, python, maintenance-mode, discord-py, bug] +importance: 0.6 +confidence: 0.8 +created: "2026-03-03T18:04:48.164825+00:00" +updated: "2026-03-03T18:04:48.164825+00:00" +--- + +## Review Summary + +**PR #62**: `fix: implement actual maintenance mode flag in /admin-maintenance (#28)` +**Verdict**: REQUEST_CHANGES (could not post — Gitea blocks self-review) + +### Key Bug Found: Double ephemeral message on maintenance gate + +When `@self.tree.interaction_check` returns `False`, discord.py dispatches `CheckFailure` to the registered `@bot.tree.error` handler (`on_app_command_error`). The existing handler does NOT handle `CheckFailure`, so it falls to the `else` branch, which: +1. Logs the error as "Unhandled command error" (incorrect) +2. Sends a second ephemeral followup: "❌ An unexpected error occurred." since `is_done()` is True + +Per discord.py docs: "If this function returns False, the invocation does not happen and the function's error handlers are called with a CheckFailure." + +### Fix Required +Add `CheckFailure` handling in `bot.py` `on_app_command_error`: +```python +elif isinstance(error, discord.app_commands.CheckFailure): + if not interaction.response.is_done(): + await interaction.response.send_message( + "❌ You don't have permission to run this command.", ephemeral=True + ) +``` + +### Files Reviewed +- `bot.py`: Added `self.maintenance_mode: bool = False` in `__init__`, nested `maintenance_check` function registered via `@self.tree.interaction_check` in `setup_hook` +- `commands/admin/management.py`: Added `self.bot.maintenance_mode = is_enabling`, logging; rest is Black formatter reformatting + +### Other Notes +- `self.bot.maintenance_mode` is not type-safe (`self.bot: commands.Bot` doesn't declare the attribute) — minor +- No tests added for the new blocking behavior +- Core logic is correct; admins pass through in maintenance mode, non-Members also blocked in DMs