Skip to content

fix(api): /ready probe always returned 200 due to tuple truthiness - #11

Merged
DJLougen merged 1 commit into
mainfrom
cursor/critical-bug-investigation-8b9c
Jun 5, 2026
Merged

fix(api): /ready probe always returned 200 due to tuple truthiness#11
DJLougen merged 1 commit into
mainfrom
cursor/critical-bug-investigation-8b9c

Conversation

@cursor

@cursor cursor Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

The FastAPI /ready endpoint in scripts/hive_api_server.py treated is_healthy(stack) as a boolean. is_healthy() returns (ready: bool, backends: dict), and any non-empty tuple is truthy in Python, so /ready returned HTTP 200 even when RustBrain was down.

Concrete trigger: Deploy hive_api_server.py behind Kubernetes with a readiness probe on /ready. If the memory backend fails (e.g. brain.stats() raises), the pod still reports ready and the load balancer keeps sending traffic — requests to /remember and /recall fail or return stale data while orchestration believes the pod is healthy.

Root cause

if is_healthy(stack):  # always True — tuple is truthy
    return JSONResponse({"status": "ready"})

The standalone HealthServer in hive/health.py correctly checks backend status; only the FastAPI wrapper had this bug.

Fix and validation

  • Unpack the tuple: ready, _backends = is_healthy(stack) and branch on ready.
  • Added regression tests in tests/test_hive_api_server.py:
    • Broken brain → 503 not_ready
    • Healthy stack → 200 ready
  • Ran pytest tests/test_hive_api_server.py tests/test_enterprise_health.py — 6/6 passed.
Open in Web View Automation 

is_healthy() returns (ready, backends). Using the tuple directly in a
boolean context is always truthy, so /ready returned 200 even when
RustBrain was down — K8s would keep routing traffic to broken pods.

Add regression tests for healthy and unhealthy stacks.

Co-authored-by: Daniel <DJLougen@users.noreply.github.com>
@DJLougen
DJLougen marked this pull request as ready for review June 5, 2026 12:07
@DJLougen
DJLougen merged commit da5663a into main Jun 5, 2026
7 checks passed
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