From 48f3a8a93edb241cc0e8d8481d507be35539599d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roosc=20Za=C3=B1o?= Date: Sat, 14 Nov 2026 10:06:21 +0800 Subject: [PATCH 1/2] fix(health): accept HEAD liveness probes --- backend/api/v1/endpoints/health.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/api/v1/endpoints/health.py b/backend/api/v1/endpoints/health.py index 70ce4b3..419dc35 100644 --- a/backend/api/v1/endpoints/health.py +++ b/backend/api/v1/endpoints/health.py @@ -1,6 +1,6 @@ import logging from datetime import datetime, timezone -from fastapi import APIRouter, HTTPException, status +from fastapi import APIRouter, HTTPException, Response, status from core.database import get_db from schemas import HealthResponse @@ -14,6 +14,12 @@ def liveness_check(): return {"status": "alive"} +@router.head("/live", include_in_schema=False) +def liveness_head_check(): + """Allow HEAD-based uptime probes without querying the database.""" + return Response(status_code=status.HTTP_200_OK) + + @router.get("/health", response_model=HealthResponse) def health_check(): conn = None From 9cd3a1e5f921e14fb3752e034767cdc00da1ea5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roosc=20Za=C3=B1o?= Date: Sat, 14 Nov 2026 10:06:29 +0800 Subject: [PATCH 2/2] test(health): cover HEAD liveness probes --- backend/test_health_http.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/backend/test_health_http.py b/backend/test_health_http.py index 4f33390..802f679 100644 --- a/backend/test_health_http.py +++ b/backend/test_health_http.py @@ -23,3 +23,15 @@ def fail_if_database_is_used(): assert response.status_code == 200 assert response.json() == {"status": "alive"} + + +def test_head_liveness_check_does_not_query_database(monkeypatch): + def fail_if_database_is_used(): + pytest.fail("liveness check must not open a database connection") + + monkeypatch.setattr(health, "get_db", fail_if_database_is_used) + + response = client.head("/api/v1/live") + + assert response.status_code == 200 + assert response.content == b""