Skip to content

Improve error handling for Discord OAuth#35

Merged
Crossedfall merged 4 commits into
masterfrom
discord-error-handling
Jun 29, 2025
Merged

Improve error handling for Discord OAuth#35
Crossedfall merged 4 commits into
masterfrom
discord-error-handling

Conversation

@itsmeow
Copy link
Copy Markdown
Member

@itsmeow itsmeow commented Jun 29, 2025

Fixes 500 Internal Server Error from bad imports and provides much more useful and distinguished error messages, while not disclosing too much information to the user.

Also handles a missing session duration and uses the default value.

image

Comment thread src/bapi/blueprints/discord.py Fixed
itsmeow and others added 2 commits June 29, 2025 15:15
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@Crossedfall Crossedfall requested a review from Copilot June 29, 2025 19:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Improves Discord OAuth error handling by replacing broad exception catches with specific ones, adding distinct error messages, and introducing a default session duration when the config value is missing.

  • Refactored imports to alias Client and bring in exception types
  • Expanded exception handling with differentiated responses and logging
  • Added fallback for missing game-session-duration and updated template rendering
Comments suppressed due to low confidence (2)

src/bapi/blueprints/discord.py:8

  • [nitpick] Consider importing the exceptions module using lowercase (e.g. import discordoauth2.exceptions as exceptions) or importing specific exception classes instead of aliasing everything under Exceptions to follow PEP8 and improve clarity.
from discordoauth2.exceptions import Exceptions

src/bapi/blueprints/discord.py:84

  • There are several new exception handling branches (e.g., RateLimited, Forbidden, HTTPException, KeyError) that should have corresponding unit tests to verify the correct status codes and error messages are returned.
    except Exceptions.Forbidden:

Comment thread src/bapi/blueprints/discord.py
Comment thread src/bapi/blueprints/discord.py
Comment thread src/bapi/blueprints/discord.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Crossedfall Crossedfall merged commit 9eda450 into master Jun 29, 2025
4 checks passed
@itsmeow itsmeow deleted the discord-error-handling branch June 30, 2025 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants