Catch wrong credentials for pSQL #6422
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot#6422
Loading…
Reference in a new issue
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?
The fact that no one caught this after all these years... is kinda funny!
Should config fallback to use the JSON driver with a specified message sent to the bot owner(s) if postgres credentials are wrong?
I would think not, as that would be an entirely separate set of data. I would say not being able to load its data because the credentials are incorrect should cause the bot to exit with the "configuration error" status code (78).
github.com/Cog-Creators/Red-DiscordBot@30058c0f73/redbot/core/_cli.py (L26)Though I am curious how we handle the database not running when the bot starts. This can probably be handled in a similar way to that as well.
Does Red initially tries to connect to postgres when starting the bot, or does it only connect individually to postgres when a cog uses Config?
is there like any "first guaranteed call to postgres" when Red initially starts when using the postgres driver?
github.com/Cog-Creators/Red-DiscordBot@30058c0f73/redbot/main.py#L300-L315github.com/Cog-Creators/Red-DiscordBot@30058c0f73/redbot/core/_drivers/postgres/postgres.py (L42-L47)Currently the pool is created in
run_bot(which is beforebot.start()), without any guards for if the pool is not online or the password is incorrect. I still would be inclined to say that the entiredriver_cls.initializecall should be wrapped in atry/exceptthatsys.exit(ExitCodes.CONFIGURATION_ERROR)on exception.Shouldn't this also be handled when lets say the creds changed during runtime?
That sounds like a very specific edge case. Credentials don't normally change during runtime. So in my opinion its fine to skip over it.
The database going offline during runtime is a less rare edge case than the credentials changing, and both would be handled similarly, so I don't think it's unreasonable to consider. That being said, it's less clear where it would be best to catch these errors during runtime, and it's less likely to be an issue than not configuring the connection correctly at the start. I'd say that handling these on bot start is much more important, and should be the main focus for someone working on this issue. Catching similar errors during runtime wouldn't hurt, but I think is lower priority.
Behoben in
46f0107d5: Falsche Zugangsdaten, eine fehlende Datenbank oder ein nicht erreichbarer Server führen nicht mehr zu einem Traceback. Red loggt den Grund und wo die Verbindungsdaten gespeichert sind und beendet sich mit Exit-Code 78 (Konfigurationsfehler).Generated by Claude Code