Guard GUILD_ID env var cast against missing/invalid value #26

Open
opened 2026-02-20 06:51:32 +00:00 by cal · 3 comments
Owner

cogs/gameplay.py:58, helpers/discord_utils.py:104, discord_utils.py:104 all call int(os.environ.get('GUILD_ID')). If unset, int(None) raises TypeError, crashing the live scoreboard task loop.

`cogs/gameplay.py:58`, `helpers/discord_utils.py:104`, `discord_utils.py:104` all call `int(os.environ.get('GUILD_ID'))`. If unset, `int(None)` raises TypeError, crashing the live scoreboard task loop.
cal added the
bug
label 2026-02-20 06:51:32 +00:00
cal added the
ai-working
label 2026-03-05 11:30:55 +00:00
cal removed the
ai-working
label 2026-03-05 11:34:55 +00:00
Author
Owner

Fixed in PR #60.

Added a guild_id = os.environ.get('GUILD_ID') guard with early return and logger.error in all three call sites before calling int(). Prevents TypeError: int() argument must be... not 'NoneType' when GUILD_ID is unset.

Note: the linter hook reformatted cogs/gameplay.py as a side effect — functional change is only the GUILD_ID guard in live_scorecard (~line 128).

Fixed in PR #60. Added a `guild_id = os.environ.get('GUILD_ID')` guard with early `return` and `logger.error` in all three call sites before calling `int()`. Prevents `TypeError: int() argument must be... not 'NoneType'` when `GUILD_ID` is unset. Note: the linter hook reformatted `cogs/gameplay.py` as a side effect — functional change is only the GUILD_ID guard in `live_scorecard` (~line 128).
cal added the
ai-pr-opened
label 2026-03-05 11:35:04 +00:00
cal removed the
ai-pr-opened
label 2026-03-10 14:14:13 +00:00
Author
Owner

PR closed; too many unrequested changes

PR closed; too many unrequested changes
Claude added the
ai-working
label 2026-03-10 14:31:09 +00:00
Claude added
ai-pr-opened
and removed
ai-working
labels 2026-03-10 14:38:05 +00:00
Collaborator

Fix implemented in PR #84: #84

Added guild_id = os.environ.get("GUILD_ID") + early-return guard before int(guild_id) in all three locations (cogs/gameplay.py, helpers/discord_utils.py, discord_utils.py). If GUILD_ID is unset the bot now logs an error and returns gracefully instead of crashing with TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'.

Fix implemented in PR #84: https://git.manticorum.com/cal/paper-dynasty-discord/pulls/84 Added `guild_id = os.environ.get("GUILD_ID")` + early-return guard before `int(guild_id)` in all three locations (`cogs/gameplay.py`, `helpers/discord_utils.py`, `discord_utils.py`). If `GUILD_ID` is unset the bot now logs an error and returns gracefully instead of crashing with `TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'`.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/paper-dynasty-discord#26
No description provided.