Repository navigation
feat(bot): send unexpected command errors to the error webhook again - #409
Conversation
Architecture Data flow Review 1 finding · reviewed
|
There was a problem hiding this comment.
ℹ️ No critical issues — two rough edges worth a look.
Approach: sound — hooking the existing commandError listener after the reply is written keeps the 500-ordering constraint and reuses the already-declared WEBHOOK_ERROR_* variables.
Reviewed changes
Reviewed the full diff (5 files, 1 commit).
reportCommandErrorToWebhook(lib/utilities/errorWebhook.ts): builds a red embed with location, command and options, failed request details and a truncated stack, and sends it throughcontainer.gatewayClient.webhooks. A failed send logs only its code.commandErrorlistener: the reply is written first, then the report is fired without being awaited (void).- Schema and
env.d.ts: drops the stale default webhook ID and documents the new errors channel. The regenerated typings also carry an unrelatedDISCORD_PUBLIC_KEYdoc line and a@ts-nocheckreorder. - Tests: cover
getErrorWebhook,isReportableCommandErrorandformatCommandErrorReport. The send path and the listener wiring are not exercised.
claude-sonnet-5-5 | 𝕏
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #409 +/- ##
==========================================
- Coverage 62.46% 62.44% -0.02%
==========================================
Files 268 269 +1
Lines 9396 9440 +44
Branches 2227 2242 +15
==========================================
+ Hits 5869 5895 +26
- Misses 3160 3169 +9
- Partials 367 376 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — deciding "unexpected" from flattenError's own result keeps the report filter and the user-facing answer from drifting.
Reviewed changes
Reviewed the delta since the prior pullfrog review (48cc819 on top of 8ee18e8).
- Token redaction:
redactRequestUrlhides/webhooks/<id>/<token>and/interactions/<id>/<token>and drops the query, and**Path**uses it. A test covers a failed follow-up. - Single source of truth for "unexpected":
isReportableCommandErroris gone. ThecommandErrorlistener callsflattenErroronce and reports only when it returnsnull, so known Discord codes and 5xx statuses stay out of the channel. handleCommandError: takes the already resolved result as an optional third argument, withflattenErroras the default for other callers. The reply is still written before anything is awaited.- Context menu commands: logged through
flattenErrorinstead of an unconditionalfatal.
claude-sonnet-5-5 | 𝕏

🔗 Linked issue
None.
❓ Type of change
📚 Description
Before V7 the bot posted the unexpected errors of its commands to a Discord webhook. The rewrite kept
WEBHOOK_ERROR_IDandWEBHOOK_ERROR_TOKENin the schema but nothing read them, so those errors only reached the logs and Sentry.The
commandErrorlistener now callsreportCommandErrorToWebhook(lib/utilities/errorWebhook.ts) after the reply is written to the user. It sends a red embed with the guild, channel and user, the command with its options, the method, path and code of a failed Discord request, and the stack cut to fit the embed. Only whatflattenErrorcannot answer the user with is reported, so user errors, aborted requests and the Discord errors that have their own message (an unknown channel, a 503) stay out. The listener asksflattenErroronce and hands its result tohandleCommandError. The path hides the token of a webhook or interaction request (redactRequestUrl). Nothing is sent unless both variables are set. A failed send logs only its code, since the URL holds the webhook token.A failed context menu command is no longer logged as
fatalfor every error:flattenErrorlogs it as it does for the slash commands.The schema loses the old default webhook ID (
648663047615021058, a webhook of the old channel) and now names the errors channel,1250081114710872146.env.d.tsis regenerated from it.📝 Migration
Create a webhook in channel
1250081114710872146, then setWEBHOOK_ERROR_IDandWEBHOOK_ERROR_TOKENon the Railway service of the bot from its URL (https://discord.com/api/webhooks/<ID>/<TOKEN>).

Confidence Score: 5/5
The PR appears safe to merge.Reviews (1) · Last reviewed commit: "fix(bot): import UserError as a type in ..." · Reviewed by Greptile