Skip to content

Conversation

Nastaliss
Copy link
Contributor

@Nastaliss Nastaliss commented Sep 26, 2025

Purpose

Move healthcheck to /api/version so that it can be used in scalingo

Summary by CodeRabbit

  • Refactor
    • Health check now uses a versioned API path (e.g., /api/vX.Y/healthz) for consistency with other routes.
  • Chores
    • Container health checks updated to target the new versioned endpoint without changing timing or behavior.
    • Reduced log noise by suppressing routine health-check request logs.

@coderabbitai
Copy link

coderabbitai bot commented Sep 26, 2025

Walkthrough

Healthcheck endpoints were moved to a versioned API path; Docker Compose healthchecks updated to call /api/v1.0/healthz/. Django routing now constructs the health route from settings.API_VERSION. WSGI log suppression was changed to suppress logs for the exact /api/v1.0/healthz path (after stripping trailing slash).

Changes

Cohort / File(s) Summary
Docker healthchecks
compose.yaml
Updated CMD-SHELL healthcheck one-liners in two services to request /api/v1.0/healthz/ instead of /healthz/, preserving timeouts and command structure.
Versioned health URL routing
src/backend/messages/urls.py
Replaced literal "healthz/" route with f"api/{settings.API_VERSION}/healthz/", so the health endpoint is served under the configured API version prefix.
WSGI log suppression (exact path)
src/backend/messages/wsgi.py
Modified QuietWSGIRequestHandler.log_message to suppress logging when path.rstrip("/") equals f"/api/{settings.API_VERSION}/healthz" (targeting the precise versioned health endpoint).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Docker as Docker Healthcheck
  participant Web as Web Server (nginx/gunicorn)
  participant WSGI as QuietWSGIRequestHandler
  participant Django as URL Router
  participant View as Health View

  Docker->>Web: GET /api/v1.0/healthz/
  activate Web
  Web->>WSGI: deliver request
  WSGI->>Django: route request
  Django->>View: call health view
  View-->>Django: 200 OK (health status)
  Django-->>WSGI: response
  WSGI-->>Web: response to client
  deactivate Web
  Note over WSGI: suppress log if path.rstrip("/") == "/api/v1.0/healthz" (exact match)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • sylvinus

Poem

A rabbit hops by, nose twitching with glee,
Versioned paths tidy where health checks now be.
Quiet the logs for that one tidy trail,
Containers blink green — my whiskers prevail. 🐇🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title correctly identifies that the healthcheck route is being moved but includes an unnecessary emoji and parentheses and generically refers to “api/version” rather than the actual versioned path, which reduces clarity and introduces noise. Please remove the emoji and parentheses and specify the concrete versioned endpoint, for example: “Move healthcheck route to /api/v1.0/healthz/.”
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch suppress-prom-logs

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d08df8 and c993dc0.

📒 Files selected for processing (2)
  • compose.yaml (2 hunks)
  • src/backend/messages/wsgi.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • compose.yaml
🧰 Additional context used
📓 Path-based instructions (1)
src/backend/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/django-python.mdc)

src/backend/**/*.py: Follow Django/PEP 8 style with a 100-character line limit
Use descriptive, snake_case names for variables and functions
Use Django ORM for database access; avoid raw SQL unless necessary for performance
Use Django’s built-in user model and authentication framework
Prefer try-except blocks to handle exceptions in business logic and views
Log expected and unexpected actions with appropriate log levels
Capture and report exceptions to Sentry; use capture_exception() for custom errors
Do not log sensitive information (tokens, passwords, financial/health data, PII)

Files:

  • src/backend/messages/wsgi.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-back
  • GitHub Check: build-front
🔇 Additional comments (2)
src/backend/messages/wsgi.py (2)

12-13: LGTM! Import is correct.

The import of settings from django.conf is standard Django practice and necessary for accessing settings.API_VERSION in the log suppression logic.


24-27: Approved – no further action required
Query string handling, trailing slash normalization, strict equality comparison, and dynamic versioning via API_VERSION are correctly implemented, and API_VERSION is defined in settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (3.3.8)
src/backend/messages/wsgi.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
compose.yaml (1)

105-148: Parameterize health-check URL with API_VERSION

Hardcoding /api/v1.0/healthz/ risks going out-of-sync with settings.API_VERSION, leading to failing health checks when the version changes. Please reference the environment variable (or reuse the same value) to keep compose aligned with Django settings.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f21a75 and a275191.

📒 Files selected for processing (3)
  • compose.yaml (2 hunks)
  • src/backend/messages/urls.py (1 hunks)
  • src/backend/messages/wsgi.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
src/backend/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/django-python.mdc)

src/backend/**/*.py: Follow Django/PEP 8 style with a 100-character line limit
Use descriptive, snake_case names for variables and functions
Use Django ORM for database access; avoid raw SQL unless necessary for performance
Use Django’s built-in user model and authentication framework
Prefer try-except blocks to handle exceptions in business logic and views
Log expected and unexpected actions with appropriate log levels
Capture and report exceptions to Sentry; use capture_exception() for custom errors
Do not log sensitive information (tokens, passwords, financial/health data, PII)

Files:

  • src/backend/messages/urls.py
  • src/backend/messages/wsgi.py
src/backend/**/urls.py

📄 CodeRabbit inference engine (.cursor/rules/django-python.mdc)

Define clear, RESTful URL patterns using Django’s URL dispatcher

Files:

  • src/backend/messages/urls.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: docker-publish-socks-proxy / docker-build-push
  • GitHub Check: check-api-state
  • GitHub Check: build-front
  • GitHub Check: lint-back
  • GitHub Check: test-back
🔇 Additional comments (1)
src/backend/messages/urls.py (1)

20-23: Ensure API version format matches compose health checks

The new route delegates to settings.API_VERSION, but compose.yaml hardcodes v1.0. If settings.API_VERSION differs (e.g., v1), the Docker health checks will 404. Please confirm the setting or parameterize the compose file so both stay in sync.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/backend/messages/wsgi.py (1)

22-22: Consider using settings.API_VERSION to avoid hardcoding.

The AI summary mentions that Django routing constructs the health route from settings.API_VERSION. Hardcoding /api/v1.0/healthz here could lead to inconsistencies if the API version changes in settings but this path is not updated.

If settings.API_VERSION is available, apply this diff to construct the path dynamically:

+from django.conf import settings
+
 # pylint: disable=all
 # Suppress access logs for healthcheck route
 try:
     import django.core.servers.basehttp
 
     class QuietWSGIRequestHandler(django.core.servers.basehttp.WSGIRequestHandler):
         def log_message(self, format, *args):
             path = getattr(self, "path", "")
             parsed_path = path.split("?", 1)[0].rstrip("/")
-            if parsed_path == "/api/v1.0/healthz":
+            if parsed_path == f"/api/{settings.API_VERSION}/healthz":
                 return
             super().log_message(format, *args)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a275191 and 4d08df8.

📒 Files selected for processing (1)
  • src/backend/messages/wsgi.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/backend/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/django-python.mdc)

src/backend/**/*.py: Follow Django/PEP 8 style with a 100-character line limit
Use descriptive, snake_case names for variables and functions
Use Django ORM for database access; avoid raw SQL unless necessary for performance
Use Django’s built-in user model and authentication framework
Prefer try-except blocks to handle exceptions in business logic and views
Log expected and unexpected actions with appropriate log levels
Capture and report exceptions to Sentry; use capture_exception() for custom errors
Do not log sensitive information (tokens, passwords, financial/health data, PII)

Files:

  • src/backend/messages/wsgi.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: docker-publish-socks-proxy / docker-build-push
  • GitHub Check: build-front
  • GitHub Check: test-back

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.

2 participants