Guard GUILD_ID env var cast against missing/invalid value
#26
Labels
No Label
ai-changes-requested
ai-failed
ai-pr-opened
ai-reviewed
ai-reviewing
ai-working
ai-working
bug
enhancement
feature
in-queue
performance
security
tech-debt
todo
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/paper-dynasty-discord#26
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
cogs/gameplay.py:58,helpers/discord_utils.py:104,discord_utils.py:104all callint(os.environ.get('GUILD_ID')). If unset,int(None)raises TypeError, crashing the live scoreboard task loop.Fixed in PR #60.
Added a
guild_id = os.environ.get('GUILD_ID')guard with earlyreturnandlogger.errorin all three call sites before callingint(). PreventsTypeError: int() argument must be... not 'NoneType'whenGUILD_IDis unset.Note: the linter hook reformatted
cogs/gameplay.pyas a side effect — functional change is only the GUILD_ID guard inlive_scorecard(~line 128).PR closed; too many unrequested changes
Fix implemented in PR #84: #84
Added
guild_id = os.environ.get("GUILD_ID")+ early-return guard beforeint(guild_id)in all three locations (cogs/gameplay.py,helpers/discord_utils.py,discord_utils.py). IfGUILD_IDis unset the bot now logs an error and returns gracefully instead of crashing withTypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'.