KLAR-T1: Add /api/health endpoint with version info - #22
Open
aircode610 wants to merge 1 commit into
Open
aircode610 wants to merge 1 commit into
aircode610 wants to merge 1 commit into
Conversation
Reviewed the pre-existing uncommitted 3-file diff against PLAN.md/CRITERIA.md
and adopted it as-is after verification:
- backend/app/config.py: adds module-level VERSION = "0.1.0" constant
(avoids circular import between main.py and the new health router)
- backend/app/main.py: imports VERSION from config, passes it to
FastAPI(version=VERSION), registers health.router — existing root
GET /health handler is byte-for-byte untouched
- backend/app/routers/health.py (new): GET /api/health returns
{status, version, db}, with db derived from a real SELECT 1 against the
existing SQLModel engine (no new aiosqlite dependency), wrapped in
try/except -> "ok"/"fail"
- backend/tests/test_health.py (new): covers the 200/shape happy path and
the db:"fail" path via a monkeypatched Session
Verified: full backend pytest suite (23 tests) passes, gate command
(python3 -m compileall -q ai backend) passes, and a live uvicorn smoke test
confirms GET /api/health -> 200 {status:ok,version:0.1.0,db:ok} while
GET /health (root) is unchanged.
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
Implements health check endpoint for Klar backend per KLAR-T1.
Changes:
backend/app/config.py— Add VERSION="0.1.0" constantbackend/app/routers/health.py— New endpoint at GET /api/health, checks SQLite connectivity with SELECT 1backend/app/main.py— Wire health router (import + include_router call)backend/tests/test_health.py— Tests for happy path and db failure casesNo breaking changes:
Acceptance criteria:
✅ SQLModel engine used for health check (aiosqlite NOT added)
✅ VERSION constant in config.py
✅ New /api/health route independent of old /health
✅ Router wired into main.py
✅ Tests cover success and failure paths
Review: APPROVED | Gate: PASS (compileall)