← Back to PRs

#17395: fix(discord): default dm config for sub-accounts to prevent silent crash

by deggertsen open 2026-02-15 18:18 View on GitHub →
channel: discord gateway size: XS
## Summary Fixes #17394 — Adding a Discord sub-account without an explicit `dm` block crashes the entire Discord plugin silently, killing all bot connections including the primary account. ## Root Cause `mergeDiscordAccountConfig()` in `src/discord/accounts.ts` does a shallow merge of base + account config. When a sub-account omits `dm` and the base's `dm` doesn't get inherited, `merged.dm` is `undefined`. Downstream code doesn't guard against this, causing a silent crash. ## Changes ### 1. Default DM config (`src/discord/accounts.ts`) - Added `DEFAULT_DM_CONFIG` (`{ enabled: true, policy: "pairing" }`) applied when neither base nor account provides a `dm` block - Safe fallback that doesn't change behavior for existing configs ### 2. Warning log (`src/discord/monitor/provider.ts`) - Logs a warning when no DM config is found, pointing operators to the correct config path ### 3. Error isolation (`src/gateway/server-channels.ts`) - Wrapped per-account startup in try/catch so one failing account cannot take down others - Failed accounts get `running: false` status with the error message logged ## Testing Reproduced the crash by configuring a Discord sub-account without a `dm` block. After this fix: - Sub-account without `dm` starts successfully with default pairing policy - Warning is logged directing the operator to add explicit config - If a sub-account fails for any reason, other accounts continue running <!-- greptile_comment --> <h3>Greptile Summary</h3> Fixes a critical bug where Discord sub-accounts without explicit `dm` configuration would crash the entire Discord plugin, taking down all bot connections. The fix applies a safe default (`dm.policy="pairing"`) when neither base nor account config provides DM settings, adds a helpful warning to guide operators, and wraps per-account startup in try-catch to isolate failures. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The fix correctly addresses the root cause (undefined dm config in shallow merge), uses a safe default that matches existing behavior (pairing policy), and adds critical error isolation. The changes are well-scoped and backward-compatible. - No files require special attention <sub>Last reviewed commit: 3746003</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs