3.3 KiB
| title | description | type | domain | tags | |||||
|---|---|---|---|---|---|---|---|---|---|
| Fix: /open-packs crash from orphaned Check-In Player packs | Check-In Player packs with hyphenated name caused empty Discord select menu (400 Bad Request) and KeyError in callback. | troubleshooting | paper-dynasty |
|
Fix: /open-packs crash from orphaned Check-In Player packs
Date: 2026-03-26 PR: #134 (hotfix branch based on prod tag 2026.3.4, merged to main) Tag: 2026.3.8 Severity: High --- any user with an orphaned Check-In Player pack could not open any packs at all
Problem
Running /open-packs returned: HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body --- In data.components.0.components.0.options: This field is required
Discord rejected the message because the select menu had zero options.
Root Cause
Two cascading bugs triggered by the "Check-In Player" pack type name containing a hyphen:
-
Empty select menu: The
pretty_namelogic used'-' not in keyto identify bare pack type names. "Check-In Player" contains a hyphen, so it fell into theelif 'Team' in key/elif 'Cardset' in keychain --- matching neither.pretty_namestayedNone, noSelectOptionwas created, and Discord rejected the empty options list. -
KeyError in callback (secondary): Even if displayed, selecting "Check-In Player" would call
self.values[0].split('-')producing['Check', 'In Player'], which matched none of the pack type tokens in theif/elifchain, raisingKeyError.
Check-In Player packs are normally auto-opened during the daily check-in (/comeonmanineedthis). An orphaned pack existed because roll_for_cards had previously failed mid-flow, leaving an unopened pack in inventory.
Fix
Three-layer fix applied to both cogs/economy.py (production) and cogs/economy_new/packs.py (main):
-
Filter at source: Added
AUTO_OPEN_TYPES = {"Check-In Player"}set. Packs with these types are skipped during grouping withcontinue, so they never reach the select menu. -
Fallback for hyphenated names: Added
else: pretty_name = keyafter theTeam/Cardsetchecks, so any future hyphenated pack type names still get a display label. -
Graceful error in callback: Replaced
raise KeyErrorwith a user-facing ephemeral message ("This pack type cannot be opened manually. Please contact Cal.") andreturn.
Also changed all "contact an admin" strings to "contact Cal" in discord_ui/selectors.py.
Lessons
- Production loads
cogs/economy.py, notcogs/economy_new/packs.py. The initial fix was applied to the wrong file. Always check which cogs are actually loaded by inspecting the bot startup logs (Loaded cog: ...) before assuming which file handles a command. - Hotfix branches based on old tags may have stale CI workflows. The
docker-build.ymlat the tagged commit had an older trigger config (branch push, not tag push), so the CalVer tag silently failed to trigger CI. Cherry-pick the current workflow into hotfix branches. - Pack type names are used as dict keys and split on hyphens throughout the open-packs flow. Any new pack type with a hyphen in its name will hit similar issues unless the grouping/parsing logic is refactored to stop using hyphen-delimited strings as composite keys.