fix(admin): automod-bypass reports success when a Discord role change fails - #26
fix(admin): automod-bypass reports success when a Discord role change fails#26SebTardif wants to merge 1 commit into
Conversation
Await addRole/removeRole on /admin automod-bypass-toggle. Reply with an ephemeral error when Discord rejects the role change, and only report success after the role update resolves. Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 22, 2026, 8:08 AM ET / 12:08 UTC. ClawSweeper reviewWhat this changesThe PR awaits Discord automod-bypass role changes, reports failures privately, and adds success and rejection regression tests. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 5 items remain The role-update fix remains necessary because current main still suppresses Discord role errors before reporting success. The behavioral approach is sound, but the branch still has the two previously reported repository-policy defects and only mock-based proof. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — execution before step 1 Assertions:
How this fits togetherThe guild-only admin command receives a Discord interaction, changes a member’s automod-bypass role, then sends the administrator a private result. Its reply determines whether staff can trust the reported moderation state after Discord accepts or rejects the role mutation. flowchart LR
A[Discord administrator] --> B[Admin command]
B --> C[Member role update]
C --> D{Discord accepts?}
D -->|Yes| E[Private success reply]
D -->|No| F[Private failure reply]
Before merge
Findings
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the await-and-return behavior, render the new failure replies with Carbon v2 components backed by automod response configuration, then attach redacted live Discord success and rejection evidence. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main discards a rejected addRole or removeRole promise and then unconditionally sends the corresponding success reply. Is this the best way to solve the issue? No: awaiting the role operation is the right behavioral core, but the new failure replies must follow the repository’s Carbon v2 and config-driven response conventions. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 17a621b47dba. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
What Problem This Solves
Fixes an issue where Discord admins running
/admin automod-bypass-togglewould be told the automod bypass role was added or removed even when Discord rejected the role change (missing permissions, role hierarchy, or API error). The member's roles stayed the same while the command reported a new security state.That false success is worse than a failed command: staff can believe someone is exempt from automod when they are not, or believe a bypass was revoked when it is still attached.
Why This Change Was Made
/admin automod-bypass-togglenow waits foraddRole/removeRoleto finish. If Discord rejects the change, the command replies with an ephemeral error and does not claim success. The previous success copy is sent only after the role update resolves./admin inactivity-warnis unchanged.User Impact
Admins get an accurate private reply about whether automod bypass was actually granted or removed. A Discord API failure no longer looks like a completed security change.
Evidence
Live
bunrun of/tmp/proof-hermit-automod.tsagainst this branch. The script calls the previous fire-and-forget handler and the patchedAutomodBypassToggle.runwith a Discord member whoseaddRole/removeRolethrowsMissing Permissions, then prints the command replies.Before this patch the command always printed the success sentence. After the patch a rejected role update prints
Failed to add/remove automod bypass role.and the success sentence is reserved for a resolved role update.Real behavior proof
Behavior or issue addressed:
/admin automod-bypass-togglereported that automod bypass was added or removed even when Discord rejected the role change, so staff could act on a false security state.Real environment tested: macOS 26.6.1 Darwin 25.6.0 arm64, Node v26.7.0, bun 1.3.14, patched checkout
/tmp/oc-impl-hermit-automodonfix/automod-bypass-role-errors(base97d3731).Exact steps or command run after this patch:
Evidence after fix: terminal output from the patched command class:
Observed result after fix: A rejected
addRole/removeRolenow repliesFailed to add automod bypass role.orFailed to remove automod bypass role.(ephemeral). The success sentence is printed only after the role update resolves.What was not tested: A live Discord guild with a real role hierarchy or missing-permissions token. The inactivity-warn thread member path is unchanged.
Origin
This behavior landed in 3e71d04 (
admin and team lead commands, 2026-04-07) and has been present for 130 days.user.addRole(...).catch(() => {})/user.removeRole(...).catch(() => {})discarded the Discord error, then the command still replied with the success sentence.Sibling
/rolealready awaitsaddRole/removeRolebefore replying. Beta Pings already replies privately when the Discord role update throws.