Nobody has started this yet — be first.
Business impact
GET /health exists for exactly one reason: to let a Docker healthcheck, a Kubernetes readiness probe, or a load balancer decide whether to keep sending this instance traffic. Right now, if Postgres goes down but Redis is still reachable (or vice versa), /health reports 200 { status: "ok" } anyway. The orchestrator sees a healthy instance and keeps routing real user traffic to it -- every POST /shorten and every cache-miss GET /:code behind that "healthy" instance then fails with a 500. On-call ends up chasing a spike in 500s against a fleet that every dashboard says is green, because the one signal that's supposed to catch this is lying. It also directly contradicts this project's own README, which explicitly promises "Returns 200 only if both checks pass, 503 otherwise."
Problem
GET /health returns 200 { status: "ok" } as long as either Postgres or Redis is reachable -- not both.
Current behavior
With Postgres down and Redis up (or vice versa), GET /health still returns HTTP 200 { status: "ok" } instead of 503 { status: "degraded" }.
Expected behavior
GET /health must return 200 { status: "ok" } only when both Postgres and Redis checks succeed. If either one fails, it must return 503 { status: "degraded", checks: {...} }, with the failing dependency marked "error" in the checks object.
Steps to reproduce
docker compose stop redis curl -s -o /dev/null -w "%{http_code}\n" http://localhost:3003/health
Or, without touching real infra, run this ticket's test (see verification below) -- it forces one dependency to fail via a mock and asserts on the status code.
Why this matters
Both dependency checks (SELECT 1 against Postgres, PING against Redis) are already run correctly via Promise.allSettled -- the bug isn't in how the checks happen, it's in how their two boolean results get combined into one overall verdict. "Healthy" should mean every check passed, not some check passed. The boolean expression combining checks.postgres === 'ok' and checks.redis === 'ok' is using the wrong operator for that.
Suggested approach
Find the line in src/routes/health.js that assigns const healthy = .... Think about what "the service is healthy" should mean when there are two independent checks, then look at which boolean operator is actually being used to combine them.
Acceptance criteria
Verification
npx jest --config practice-tickets/jest.config.js practice-tickets/tests/01-health-check-false-positive.test.js
Hints (0/2)
Try it without hints first — the reading is the exercise.
Working on this ticket
Work on a branch named for the ticket — that's what you'll submit.
Branch off your fork
$git checkout -b fix/health-check-false-positiveFix it and commit
Meet every acceptance criterion, and add a test that would have caught this.
Push the branch
$git push -u origin fix/health-check-false-positiveSubmit it below
Paste your fork URL and the branch name, with a short write-up of the root cause.
Questions
Ask about anything unclear in the ticket — the maintainer and anyone who has solved it can answer. Please don't post full solutions.
Sign in to ask a question or reply.
Sign inOr run the whole stack in Docker instead of the steps above -- docker compose up --build (dev, hot-reloaded via a bind-mounted src/) or docker compose -f docker-compose.prod.yml up --build (prod-style multi-stage build, non-root user). Either way the app container runs prisma migrate deploy on startup, so no separate migration step is needed. Host ports are non-default -- app 3003, Postgres 5436, Redis 6380 -- to avoid clashing with sibling projects in this repo.
The project's own real test suite (npm test, Jest + Supertest against real Postgres/Redis) is separate from the practice tickets below -- run it any time to confirm you haven't broken anything already-working.
Each ticket in practice-tickets/tickets/ (01 through 07) names a dedicated test under practice-tickets/tests/, run via its own Jest project (practice-tickets/jest.config.js, excluded from plain npm test):
# a single ticket
npx jest --config practice-tickets/jest.config.js practice-tickets/tests/01-health-check-false-positive.test.js
# all 7, one at a time, with a pass/fail summary
./practice-tickets/run.sh
Fixing tickets 01, 03, 04, and 07 also turns several pre-existing failures in the real suite (tests/health.test.js, tests/redirect.test.js, tests/concurrency.test.js) back to green -- that's expected, not a coincidence, since the injected bugs live in shared code that suite also exercises. tests/concurrency.test.js specifically fails for two unrelated reasons at once (tickets 04 and 07 both touch code paths it exercises), so fixing only one of the two will not turn it green.
Level 1
Fix a bug
Read existing behaviour, correct it.