Skip to content

fix(discord): delete obsolete slash commands before creating (avoid 100-cap error 30032) - #50992

Merged
teknium1 merged 2 commits into
mainfrom
salvage/50890-discord-slash-cap
Jun 22, 2026
Merged

fix(discord): delete obsolete slash commands before creating (avoid 100-cap error 30032)#50992
teknium1 merged 2 commits into
mainfrom
salvage/50890-discord-slash-cap

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Discord slash-command sync no longer fails with error 30032 ("ALL slash commands broken") when an app at the 100-command cap needs a new command.

Discord enforces a hard 100-command limit per app and rejects an upsert that would push the live total over 100. The sync created new commands before deleting obsolete ones, so an app already at the cap momentarily reached 101 mid-sync and the whole operation was rejected — silently disabling every slash command. This is the second, separate error visible later in NilVaw's cron log (the first being the cron RuntimeError, fixed in #50989).

Changes

  • plugins/platforms/discord/adapter.py: compute obsolete_keys = existing − desired and delete them first, then run the create/update loop. Removes the now-redundant trailing delete loop. The live total never rises above the cap mid-sync.

Validation

Before After
App at 100/100, +1 new command create → 101 → error 30032 (all commands broken) delete obsolete first → stays ≤ 100 → succeeds

tests/gateway/test_discord_sync_limit.py (new regression test asserting deletions precede creations) + tests/gateway/test_discord_connect.py → all passing.

Salvage of #50890 by @infinitycrew39 — the regression test cherry-picked with authorship preserved; the adapter reorder re-applied to current main (the original adapter diff no longer applied after the platform refactor) under maintainer authorship. Reported by NilVaw in Discord.

Infographic

discord-slash-sync-delete-before-create

infinitycrew39 and others added 2 commits June 22, 2026 12:20
Add a test to verify that _safe_sync_slash_commands deletes obsolete
commands before creating new ones. This ensures we never temporarily
exceed Discord's 100-command limit during sync, which would trigger
error 30032 and break all slash commands.

This test guards against the regression where sync could fail even though
the registration cap was properly enforced.
Discord enforces a hard 100-command limit per app and rejects an upsert that would push the live total over 100 (error 30032), which silently breaks ALL slash commands. The sync deleted obsolete commands AFTER creating new ones, so an app already at the cap momentarily exceeded it and the whole sync failed.

Reorder: delete no-longer-desired commands up front, then create/update. Removes the now-redundant trailing delete loop. Adapts @infinitycrew39 PR #50890 to current main (the original adapter diff no longer applied after the platform refactor); test commit cherry-picked with authorship preserved.
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: salvage/50890-discord-slash-cap vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 11455 on HEAD, 11444 on base (🆕 +11)

🆕 New issues (7):

Rule Count
invalid-assignment 4
unresolved-attribute 2
unresolved-import 1
First entries
tests/gateway/test_discord_sync_limit.py:85: [invalid-assignment] invalid-assignment: Object of type `MagicMock` is not assignable to attribute `_patchable_app_command_payload` of type `def _patchable_app_command_payload(self, payload: dict[str, Any]) -> dict[str, Any]`
run_agent.py:2984: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
tests/gateway/test_discord_sync_limit.py:84: [invalid-assignment] invalid-assignment: Object of type `MagicMock` is not assignable to attribute `_canonicalize_app_command_payload` of type `def _canonicalize_app_command_payload(self, payload: dict[str, Any]) -> dict[str, Any]`
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
tests/gateway/test_discord_sync_limit.py:7: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
tests/gateway/test_discord_sync_limit.py:82: [invalid-assignment] invalid-assignment: Object of type `AsyncMock` is not assignable to attribute `_sleep_between_command_sync_mutations` of type `def _sleep_between_command_sync_mutations(self) -> CoroutineType[Any, Any, None]`
tests/gateway/test_discord_sync_limit.py:83: [invalid-assignment] invalid-assignment: Object of type `MagicMock` is not assignable to attribute `_existing_command_to_payload` of type `def _existing_command_to_payload(self, command: Any) -> dict[str, Any]`

✅ Fixed issues (1):

Rule Count
invalid-assignment 1
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`

Unchanged: 6027 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter duplicate This issue or pull request already exists labels Jun 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #46078 (merged) — the root-cause fix already caps the desired command set at 100, so the live total can't exceed the cap mid-sync. The delete-before-create reorder here is the band-aid approach already covered by that cluster (#40699, #28800, #29134, #24371, #19366). This PR is a salvage of #50890 (@infinitycrew39). Marking duplicate of the canonical merged fix.

@teknium1
teknium1 merged commit e9b86f3 into main Jun 22, 2026
35 checks passed
@teknium1
teknium1 deleted the salvage/50890-discord-slash-cap branch June 22, 2026 20:58
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 duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have platform/discord Discord bot adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants