Skip to content

Health check endpoint clean - #80

Closed
Flor125 wants to merge 6 commits into
Deen-Bridge:devfrom
Flor125:health-check-endpoint-clean
Closed

Health check endpoint clean#80
Flor125 wants to merge 6 commits into
Deen-Bridge:devfrom
Flor125:health-check-endpoint-clean

Conversation

@Flor125

@Flor125 Flor125 commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Fixed the problem about flake8, the imports of main.py and added extensions on .gitignore

Summary by CodeRabbit

  • New Features

    • Added a structured /health endpoint reporting service readiness and dependency status.
    • Configured hosting health monitoring to use the new health endpoint.
  • Documentation

    • Updated API documentation to distinguish liveness checks from detailed health checks.
  • Chores

    • Improved automated health-check pings with timeout and retry handling.
    • Added common local environment files to the ignore list.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The service adds a structured /health endpoint, configures Render and the keep-awake workflow to use it, and updates API documentation. Repository cleanup adds ignore rules and removes contents from selected files under venv/.

Changes

Health endpoint integration

Layer / File(s) Summary
Health response implementation
main.py
Adds get_health_status, returns JSON health data, and selects HTTP 200 or 503 based on GEMINI_API_KEY configuration.
Health check wiring and documentation
render.yaml, .github/workflows/keep-render-awake.yml, README.md
Configures Render to check /health, updates the workflow curl request with timeout/retry flags, and documents the liveness and structured health endpoints.

Repository environment cleanup

Layer / File(s) Summary
Ignore generated environment files
.gitignore
Ignores venv/ and .DS_Store.
Remove selected virtual-environment contents
venv/...
Removes prior contents from selected pip metadata, pip internals, network, and Rich utility files.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant FastAPI
  participant get_health_status
  Client->>FastAPI: GET /health
  FastAPI->>get_health_status: Evaluate configured checks
  get_health_status-->>FastAPI: Health payload and status code
  FastAPI-->>Client: JSON response
Loading

Suggested reviewers: zeemscript

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main health-check endpoint update and cleanup work in this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@main.py`:
- Around line 1245-1248: Update the health endpoint’s deep handling around the
deep and key_configured branches: either implement a bounded, offloaded Gemini
reachability probe and report its result in checks with a non-200 response when
unavailable, or remove the deep flag and clearly keep the endpoint
configuration-only. Do not label Gemini as “skipped” while still claiming
healthy.

In `@README.md`:
- Around line 50-57: Resolve the README API table conflict by preserving the
`/memory/{user_id}` GET and DELETE rows, the updated `/ping` description, and
the `/health` row, then remove all `<<<<<<<`, `=======`, and `>>>>>>>` markers
so the table is valid Markdown.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

Comment thread main.py
Comment on lines +1245 to +1248
if deep:
checks["gemini_api_reachable"] = "skipped"
if key_configured:
return {"status": "ok", "version": app.version, "checks": checks}, 200

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate the relevant file and inspect the surrounding code.
python3 - <<'PY'
from pathlib import Path
p = Path('main.py')
print('exists=', p.exists())
if p.exists():
    lines = p.read_text().splitlines()
    for start in [1210, 1230, 1240, 1245, 1250]:
        s = max(1, start)
        e = min(len(lines), start + 30)
        print(f"\n--- main.py {s}-{e} ---")
        for i in range(s, e + 1):
            print(f"{i:5d}: {lines[i-1]}")
PY

# Find health-related symbols and deep check references.
rg -n "deep|gemini_api_reachable|health|render|GEMINI_API_KEY|status\": \"ok\"" main.py

Repository: Deen-Bridge/dnb-ai

Length of output: 7473


Make /health?deep=true either probe Gemini or drop the flag.
deep=true currently only adds "gemini_api_reachable": "skipped" and still returns 200 whenever GEMINI_API_KEY is set, so this can report healthy even when Gemini is unavailable. If this endpoint is meant to gate deploy health, add a bounded async/offloaded reachability check; otherwise make it explicitly configuration-only.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@main.py` around lines 1245 - 1248, Update the health endpoint’s deep handling
around the deep and key_configured branches: either implement a bounded,
offloaded Gemini reachability probe and report its result in checks with a
non-200 response when unavailable, or remove the deep flag and clearly keep the
endpoint configuration-only. Do not label Gemini as “skipped” while still
claiming healthy.

Source: Path instructions

Comment thread README.md
Comment on lines +50 to +57
<<<<<<< HEAD
| `GET` | `/memory/{user_id}` | Retrieve a stored user profile (transparency) |
| `DELETE` | `/memory/{user_id}` | Completely erase a stored user profile |
| `GET` | `/ping` | Health check |
=======
| `GET` | `/ping` | Trivial liveness check (always returns 200) |
| `GET` | `/health` | Structured health check - status, version and dependency checks. Returns 200 if all checks pass, 503 otherwise |
>>>>>>> 0e603a2 (Add /health endpoint, healthCheckPath, and fix keep-awake workflow)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Resolve the merge conflict before merging.

The literal <<<<<<<, =======, and >>>>>>> markers break the API table and cause the reported markdownlint table errors. Keep the memory rows, retain the updated /ping description and /health row, then remove all conflict markers.

🧰 Tools
🪛 markdownlint-cli2 (0.23.0)

[warning] 50-50: Table pipe style
Expected: leading_and_trailing; Actual: no_leading_or_trailing; Missing leading pipe

(MD055, table-pipe-style)


[warning] 50-50: Table pipe style
Expected: leading_and_trailing; Actual: no_leading_or_trailing; Missing trailing pipe

(MD055, table-pipe-style)


[warning] 50-50: Table column count
Expected: 3; Actual: 1; Too few cells, row will be missing data

(MD056, table-column-count)


[warning] 54-54: Table pipe style
Expected: leading_and_trailing; Actual: no_leading_or_trailing; Missing leading pipe

(MD055, table-pipe-style)


[warning] 54-54: Table pipe style
Expected: leading_and_trailing; Actual: no_leading_or_trailing; Missing trailing pipe

(MD055, table-pipe-style)


[warning] 54-54: Table column count
Expected: 3; Actual: 1; Too few cells, row will be missing data

(MD056, table-column-count)


[warning] 56-56: Tables should be surrounded by blank lines

(MD058, blanks-around-tables)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 50 - 57, Resolve the README API table conflict by
preserving the `/memory/{user_id}` GET and DELETE rows, the updated `/ping`
description, and the `/health` row, then remove all `<<<<<<<`, `=======`, and
`>>>>>>>` markers so the table is valid Markdown.

Source: Linters/SAST tools

@Flor125 Flor125 closed this Jul 27, 2026
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