feat: Add /health/version endpoint to verify deployed commit #974
+164
−1
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
Adds a new
/health/versionendpoint that returns the current git commit hash, making it easy to verify that a deployment has completed successfully.Problem
After merging a PR, there's no easy way to confirm the fix has been deployed to production. You'd have to SSH into the server and run
git rev-parse HEAD.Solution
New endpoint that exposes git version information:
Response (200 OK):
{ "timestamp": "2025-12-25T08:30:00Z", "git": { "commit": "abc123def456789012345678901234567890abcd", "short": "abc123d", "branch": "master" } }Response when git unavailable (503):
{ "timestamp": "2025-12-25T08:30:00Z", "git": { "commit": null, "short": null, "branch": null }, "error": "Could not retrieve version information" }Usage Examples
Verify a specific commit is deployed
Script to wait for deployment
Files Changed
mod_health/controllers.pyget_git_info()helper and/health/versionendpointtests/test_health/test_controllers.pyTests Added
test_version_endpoint_returns_200_with_git_info- Endpoint returns 200 with commit infotest_version_endpoint_returns_503_when_git_unavailable- Endpoint returns 503 when git failstest_get_git_info_success- Helper function returns correct valuestest_get_git_info_git_not_available- Graceful handling when git not installedtest_get_git_info_not_a_repo- Graceful handling when not a git repositorySecurity Considerations
🤖 Generated with Claude Code