fix(api): /ready probe always returned 200 due to tuple truthiness - #11
Merged
Conversation
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
marked this pull request as ready for review
June 5, 2026 12:07
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.
Bug and impact
The FastAPI
/readyendpoint inscripts/hive_api_server.pytreatedis_healthy(stack)as a boolean.is_healthy()returns(ready: bool, backends: dict), and any non-empty tuple is truthy in Python, so/readyreturned HTTP 200 even when RustBrain was down.Concrete trigger: Deploy
hive_api_server.pybehind 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/rememberand/recallfail or return stale data while orchestration believes the pod is healthy.Root cause
The standalone
HealthServerinhive/health.pycorrectly checks backend status; only the FastAPI wrapper had this bug.Fix and validation
ready, _backends = is_healthy(stack)and branch onready.tests/test_hive_api_server.py:not_readyreadypytest tests/test_hive_api_server.py tests/test_enterprise_health.py— 6/6 passed.