[FIN-27]Fixes for the wrong status showing for gateway health - #31
Merged
ishaanbhela-ai merged 1 commit intoSep 24, 2026
Merged
Conversation
Ayan-josh-05
approved these changes
Sep 22, 2026
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Guard non-object upstream JSON responses before accessing their status.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
Fixes gateway health aggregation and makes backend startup resilient to bind-mounted script permissions.
Changes:
- Parses downstream health responses accurately.
- Runs the startup script through Bash.
- Marks the startup script executable.
| File | Summary |
|---|---|
lending-poc/scripts/start-combined.sh |
Starts and supervises backend services. |
lending-poc/gateway/main.py |
Parses and aggregates downstream health statuses. |
lending-poc/Dockerfile |
Invokes the startup script through Bash. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+142
to
+159
| if resp.status_code >= 500: | ||
| try: | ||
| body_status = resp.json().get("status") | ||
| except ValueError: | ||
| body_status = None | ||
| if isinstance(body_status, str) and body_status: | ||
| if body_status in _HEALTHY_UPSTREAM_STATUSES: | ||
| return f"unhealthy ({resp.status_code})" | ||
| return body_status | ||
| return f"unhealthy ({resp.status_code})" | ||
|
|
||
| if resp.status_code >= 400: | ||
| return f"unhealthy ({resp.status_code})" | ||
|
|
||
| try: | ||
| body_status = resp.json().get("status") | ||
| except ValueError: | ||
| body_status = None |
ishaanbhela-ai
approved these changes
Sep 24, 2026
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.

Ticket : https://legal-ai-josh.atlassian.net/browse/FIN-27
Summary
GET /healthso it reports the actual status of OCR, translation, field-mapping, and app instead of treating every HTTP 200 as healthy.{"status":"unreachable"}or{"status":"unhealthy"}; the gateway now reads that body and normalizes"ok"/"healthy"to"healthy".scripts/start-combined.shby running it viabash, and mark the script executable in git.Problem
GET /healthalways returned something like:{"status":"healthy","services":{"ocr":"healthy","translation":"healthy","field_mapping":"healthy","app":"healthy"}} **Changes** gateway/main.py: add _status_from_upstream / _probe_service to map upstream health bodies and connection failures correctly; aggregate status is healthy only when all services are healthy, otherwise degraded. Dockerfile: CMD ["bash", "scripts/start-combined.sh"] so startup does not depend on the +x bit under bind mounts. scripts/start-combined.sh: mode 100644 → 100755 (executable). **Test plan** 1. docker compose up -d starts successfully (no permission denied on start-combined.sh) 2. With stack healthy + Ollama model pulled: curl -s http://localhost:8080/health shows all services healthy 3. docker compose stop ollama then recheck /health → status: degraded, translation/field_mapping not healthy (unreachable / similar) 4. docker compose start ollama and confirm health recovers after model is available Spot-check namespaced routes: /ocr/health, /translation/health, /field-mapping/health, /app/health