fix: return 503 when database is unreachable instead of generic 500#93
Merged
fix: return 503 when database is unreachable instead of generic 500#93
Conversation
- Login: wrap DB viewer lookup in try/except, fall through to master env var credentials when DB is down. Return 503 only if the failed login cannot be resolved without the database. - Audit log writes: wrap in try/except so they never crash the login flow. - Data endpoints: all 13 existing catch-all handlers now return 503 "Database temporarily unavailable" for connection errors (OSError in the exception chain), keeping 500 for non-connection errors. - Global exception handler: catches unhandled DB connection errors from admin endpoints and any other uncovered paths. - Health endpoint: GET /api/health returns DB connectivity status (200/503). Closes #92 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/healthreturns DB connectivity status (200 ok / 503 degraded).Closes #92
Test plan
bs4dependency)/api/healthreturns{"status": "degraded", "database": "unreachable"}with 503🤖 Generated with Claude Code