Skip to content

feat(health): enhance health check to report database connection status #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

8806667653
Copy link

  1. Enhanced the /v0/health endpoint to check database connectivity.
  2. The health handler now performs a lightweight database operation and returns "status": "db_error" with HTTP 503 if the database is unhealthy.
  3. Updated unit and integration tests to cover both healthy and unhealthy database scenarios.
  4. improved the test script (test_endpoints.sh) to detect and report database health errors.
  5. Updated API documentation (Swagger/OpenAPI) to document the new 503 response and db_error status.

Motivation and Context

Previously, the /v0/health endpoint only indicated if the service was running, without verifying database connectivity. This could result in false positives where the service appears healthy even if the database is down.
With this change, the health endpoint now checks the actual database connection and reports a "db_error" status with a 503 response if the database is unavailable. This provides more accurate health monitoring for deployments and automated systems, enabling better reliability and faster detection of backend issues.

How Has This Been Tested?

The endpoint was tested using the provided test script (test_endpoints.sh) and by running the application with and without a reachable database to verify real-world behaviour.

Breaking Changes

No, users do not need to update their code or configurations. The health check endpoint remains at the same URL and accepts the same requests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • [X ] New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • [ X] Documentation update

Checklist

  • [x ] I have read the MCP Documentation
  • [x ] My code follows the repository's style guidelines
  • [ x] New and existing tests pass locally
  • [x ] I have added appropriate error handling
  • [ x] I have added or updated documentation as needed

Additional context

I have started my journey for the first time doing a contribution. Thanks to all for your support.

@8806667653
Copy link
Author

Please merge or do i have anything pending?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant