feat(health): ping database and Redis, return 503 on failure #126
feat(health): ping database and Redis, return 503 on failure #126Janeeshareddy wants to merge 4 commits into
Conversation
|
@Janeeshareddy is attempting to deploy a commit to the rishabhmishra0510-5147's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds a Redis client singleton module and replaces the static ChangesHealth Endpoint Enhancement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hey @rishabh0510rishabh, fixed the main.py content issue. PR is ready for review! |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/app/cache.py`:
- Line 1: Remove the shell heredoc wrapper lines from backend/app/cache.py:
delete the leading "cat > backend/app/cache.py << 'EOF'" line and the trailing
"EOF" line so the file contains only valid Python code; then verify the module
(cache.py) imports cleanly and contains the intended Python definitions
(functions/classes) without the heredoc tokens.
In `@backend/tests/unit/test_health.py`:
- Line 35: The tests are patching the wrong symbol: AsyncSessionLocal is
imported inside the /health route handler, so patching
app.main.AsyncSessionLocal has no effect; update the tests to patch the symbol
where the handler imports it (patch "app.routes.health.AsyncSessionLocal" or the
module that defines the health endpoint) so the mock returned by
AsyncSessionLocal is used during the request, and adjust the existing patch(...)
calls in the test_health tests to reference AsyncSessionLocal in the health
route module.
- Line 1: Remove the accidental heredoc wrapper lines from the test file so it
contains only valid Python test code (delete the leading "cat > ... << 'EOF'"
and trailing "EOF"), and update the patch target used in the test from
patch("app.main.AsyncSessionLocal", ...) to
patch("app.database.AsyncSessionLocal", ...) while leaving
patch("app.cache.get_redis_client", ...) unchanged; ensure imports and any
patched fixtures reference AsyncSessionLocal and get_redis_client accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 99c95adb-8d3f-473f-87a0-70616f308240
📒 Files selected for processing (3)
backend/app/cache.pybackend/app/main.pybackend/tests/unit/test_health.py
|
hey @Janeeshareddy address all coderabbit review and fix test fails |
|
some checks still failed, please review them and make updates accordingly |
Closes #78
Changes
backend/app/cache.py— new Redis client manager (singleton, optional if redis_url not set)backend/app/main.py— updated /health to async-ping PostgreSQL and Redis with 2s timeoutbackend/tests/unit/test_health.py— 5 tests covering all scenariosBehavior
"status": "healthy""status": "degraded""status": "degraded""status": "degraded""redis": "not_configured"Summary by CodeRabbit
New Features
Tests