Skip to content

fix(gateway): handle Discord error 30032 gracefully on reconnect - #22757

Closed
itenev wants to merge 1 commit into
NousResearch:mainfrom
itenev:fix/gateway-discord-30032-error-handling
Closed

fix(gateway): handle Discord error 30032 gracefully on reconnect#22757
itenev wants to merge 1 commit into
NousResearch:mainfrom
itenev:fix/gateway-discord-30032-error-handling

Conversation

@itenev

@itenev itenev commented May 9, 2026

Copy link
Copy Markdown
Contributor

When Discord returns error 30032 (max application commands reached), skip the verbose stack trace on every reconnect. This is a configuration issue, not a transient failure.

Instead of logging a full traceback each time the gateway reconnects, emit a single concise warning suggesting the user consolidate commands.

What does this PR do?

This PR fixes excessive log noise during Discord gateway reconnections.

When a Discord application reaches the hard limit of 100 slash commands, the gateway attempts to sync commands on every reconnect and receives error code 30032 ("Maximum number of application commands reached").

Previously, this triggered a full warning log with a stack trace on every single reconnection, cluttering logs and potentially masking real issues. This PR detects error 30032 specifically and replaces the verbose stack trace with a single, concise warning message advising the user to consolidate their commands.

Related Issue

N/A

Type of Change

  • 🐛 Bug fix (improves logging behavior and robustness)

Changes Made

  • gateway/platforms/discord.py:
    • Added _is_discord_max_commands_error() static method to identify error code 30032.
    • Updated _run_post_connect_initialization exception handling to suppress stack traces for this specific error.

How to Test

  1. Ensure your Discord app has 100+ slash commands registered (or trigger the error manually if possible).
  2. Restart the gateway or force a reconnection.
  3. Verify that errors.log does not contain a traceback for error 30032.
  4. Verify that agent.log contains a concise warning: "Slash command sync skipped: Discord application has reached the maximum of 100 commands..."

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(gateway): handle Discord error 30032 gracefully on reconnect`)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run 'pytest tests/gateway/ -k discord' and all relevant tests pass
  • I've added tests for my changes (logic is defensive logging; difficult to mock specific HTTPException behavior in integration without extensive setup)
  • I've tested on my platform: Ubuntu 24.04

Documentation & Housekeeping

  • N/A (No documentation changes required)
  • N/A (No config keys changed)
  • N/A (Architecture unchanged)
  • I've considered cross-platform impact — No platform-specific code changed.
  • N/A (No tool behavior changed)

When Discord returns error 30032 (max application commands reached),
skip the verbose stack trace on every reconnect.  This is a
configuration issue, not a transient failure.

Instead of logging a full traceback each time the gateway reconnects,
emit a single concise warning suggesting the user consolidate commands.
@itenev
itenev marked this pull request as ready for review May 9, 2026 18:51
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/discord Discord bot adapter comp/gateway Gateway runner, session dispatch, delivery labels May 9, 2026
@itenev itenev closed this May 10, 2026
@itenev
itenev deleted the fix/gateway-discord-30032-error-handling branch May 10, 2026 12:44
@itenev
itenev restored the fix/gateway-discord-30032-error-handling branch May 11, 2026 19:15
@itenev itenev reopened this May 11, 2026
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Closing in favor of #46078 (merged), which removes the error-30032 failure at its source rather than silencing the resulting log traceback. With the desired set bounded at registration, the 30032 sync rejection no longer occurs. Thanks for the report.

@itenev
itenev deleted the fix/gateway-discord-30032-error-handling branch July 6, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/discord Discord bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants