Enhance /api/healthz with DB connectivity check#1072
Merged
Conversation
- Execute SELECT 1 against the database to verify connectivity - Return 503 with error detail when any check fails - Add test coverage for healthy, DB-down, and unauthenticated cases
catinhere
added a commit
that referenced
this pull request
Apr 13, 2026
catinhere
approved these changes
Apr 13, 2026
Contributor
catinhere
left a comment
There was a problem hiding this comment.
LGTM and executed everything under the test plan
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
{'status': 'OK'}response with a real health check that verifies database connectivity503 Service Unavailable(with error detail) when any check fails, so monitoring services can detect outagesChanges
compair/api/healthz.pySELECT 1against the database to confirm connectivitychecksmap ({"db": "ok"|"error"}) for granular visibility200when all checks pass,503otherwisecompair/tests/api/test_healthz.py(new)test_healthz_returns_200_when_db_is_up— happy pathtest_healthz_returns_503_when_db_is_down— DB failure mocked viamock.patchtest_healthz_requires_no_authentication— confirms endpoint is publicly reachableTest plan
docker exec -it compair_app_1 python -m pytest compair/tests/api/test_healthz.py -vGET /api/healthzon a running instance and confirm200 {"status": "ok", "checks": {"db": "ok"}}503when the DB is unreachable