feat: add status endpoints and mock data for component readiness and version traceability#1571
Conversation
…version traceability
WalkthroughThis PR adds a mock component status dashboard API with five authenticated endpoints (GET /v1/status, POST refresh/sync, GET logs/diagnostics) and supporting helpers to generate scenario-driven status payloads. It also adds API key provider handling in the user service to resolve API key–authenticated users to existing owners by id or email, with a test to verify the behavior. ChangesStatus Dashboard API
API Key User Resolution
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tests/unit/services/test_user_service_bootstrap.py (1)
80-113: ⚡ Quick winCover the email-fallback branch explicitly in this test.
Line 100 currently uses
uid="owner-subject", which hitsget_by_idand may miss regressions in the newget_by_emailfallback path. Use a non-matching API-keyuidwhile keeping the same email.Suggested test tweak
api_key_user = await ensure_user_row( session, _user( - uid="owner-subject", + uid="api-key-subject-does-not-match-owner-id", email="owner@example.com", name="Owner", provider="api_key", ), )🤖 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 `@tests/unit/services/test_user_service_bootstrap.py` around lines 80 - 113, The test currently uses the same uid for both the original owner and the api_key user which exercises get_by_id but not the get_by_email fallback; modify the api_key case in test_api_key_user_reuses_existing_owner_row_by_email so the second call to ensure_user_row/_user uses a different uid (e.g., a non-matching API-key uid) while keeping the same email and provider="api_key", so the code takes the get_by_email path and still reuses the existing owner row (asserts on api_key_user.id == owner.id and oauth_provider == "google" remain).src/api/v1/status.py (1)
296-307: ⚡ Quick win
mockquery parameter is currently ignored.Line 297 accepts
mock, but Line 307 always returns mock data. Either remove this parameter for now or rejectmock=falseexplicitly (e.g., 501) to avoid ambiguous API behavior.🤖 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 `@src/api/v1/status.py` around lines 296 - 307, The get_status_endpoint function currently accepts a mock query parameter but always returns mock data via build_mock_status, so either remove the mock parameter from get_status_endpoint signature and docs, or explicitly handle mock==False by returning a 501 Not Implemented response (or raising an HTTPException) indicating live status is not supported yet; update the function body to check the mock boolean and branch accordingly, referencing get_status_endpoint and build_mock_status to locate the code to change.
🤖 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 `@src/api/v1/status.py`:
- Around line 296-300: The endpoint parameters in get_status_endpoint (and the
other endpoints noted) use function call defaults (Query(...), Depends(...))
which triggers B008; change those parameter declarations to use typing.Annotated
types instead (e.g., replace "mock: bool = Query(...)" with "mock:
Annotated[bool, Query(...)]" and "user: User = Depends(...)" with "user:
Annotated[User, Depends(get_api_key_user_async)]") so the call is inside the
annotation rather than the default value; update imports to include Annotated
from typing (or typing_extensions if needed) and apply the same pattern to the
other functions referenced (the signatures around lines 310-312, 333-336,
364-368, 391-393) using their respective parameter names and
dependency/callables (Query, Depends).
---
Nitpick comments:
In `@src/api/v1/status.py`:
- Around line 296-307: The get_status_endpoint function currently accepts a mock
query parameter but always returns mock data via build_mock_status, so either
remove the mock parameter from get_status_endpoint signature and docs, or
explicitly handle mock==False by returning a 501 Not Implemented response (or
raising an HTTPException) indicating live status is not supported yet; update
the function body to check the mock boolean and branch accordingly, referencing
get_status_endpoint and build_mock_status to locate the code to change.
In `@tests/unit/services/test_user_service_bootstrap.py`:
- Around line 80-113: The test currently uses the same uid for both the original
owner and the api_key user which exercises get_by_id but not the get_by_email
fallback; modify the api_key case in
test_api_key_user_reuses_existing_owner_row_by_email so the second call to
ensure_user_row/_user uses a different uid (e.g., a non-matching API-key uid)
while keeping the same email and provider="api_key", so the code takes the
get_by_email path and still reuses the existing owner row (asserts on
api_key_user.id == owner.id and oauth_provider == "google" remain).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a3abd7d7-5485-4457-95e6-1485b498b464
📒 Files selected for processing (4)
src/api/v1/status.pysrc/app/routes/public_v1.pysrc/services/user_service.pytests/unit/services/test_user_service_bootstrap.py
| async def get_status_endpoint( | ||
| mock: bool = Query(default=True), | ||
| scenario: str = Query(default="degraded", pattern="^(healthy|degraded|offline)$"), | ||
| user: User = Depends(get_api_key_user_async), | ||
| ): |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, check if the file exists and explore its structure
fd -t f "status.py" src/api/v1/Repository: langflow-ai/openrag
Length of output: 84
🏁 Script executed:
# Get an overview of the file size and line count
wc -l src/api/v1/status.pyRepository: langflow-ai/openrag
Length of output: 88
🏁 Script executed:
# Read the specific lines mentioned in the review comment (296-300)
sed -n '296,300p' src/api/v1/status.pyRepository: langflow-ai/openrag
Length of output: 272
🏁 Script executed:
# Also check the other lines mentioned
sed -n '310,312p' src/api/v1/status.py
sed -n '333,336p' src/api/v1/status.py
sed -n '364,368p' src/api/v1/status.py
sed -n '391,393p' src/api/v1/status.pyRepository: langflow-ai/openrag
Length of output: 516
🏁 Script executed:
# Check the imports at the top of the file to see what's currently imported
head -30 src/api/v1/status.pyRepository: langflow-ai/openrag
Length of output: 966
🏁 Script executed:
# Check if there's a flake8/ruff/pycodestyle configuration
fd -t f "\.flake8|pyproject\.toml|ruff\.toml|setup\.cfg" . | head -5Repository: langflow-ai/openrag
Length of output: 135
🏁 Script executed:
# Check Python version requirements or minimum version
fd -t f "pyproject\.toml|setup\.py|requirements" . | xargs grep -l "python" 2>/dev/null | head -3Repository: langflow-ai/openrag
Length of output: 135
🏁 Script executed:
# Verify the Annotated pattern is correct by checking if it's used elsewhere in the codebase
rg "Annotated\[" src/api/ -A 2 | head -30Repository: langflow-ai/openrag
Length of output: 45
🏁 Script executed:
# Check Python version requirement and linter config
cat pyproject.toml | head -80Repository: langflow-ai/openrag
Length of output: 2230
🏁 Script executed:
# Specifically look for linting configuration
rg "flake8|ruff|pycodestyle|B008" pyproject.toml -A 3Repository: langflow-ai/openrag
Length of output: 422
Switch dependency parameters to Annotated to resolve B008 linting violations.
Ruff is flagging function calls in default arguments (B008). Use Annotated[..., Depends(...)] and Annotated[..., Query(...)] in endpoint signatures instead.
Example fix pattern across endpoints
-from typing import Any, Literal
+from typing import Annotated, Any, Literal
@@
async def get_status_endpoint(
- mock: bool = Query(default=True),
- scenario: str = Query(default="degraded", pattern="^(healthy|degraded|offline)$"),
- user: User = Depends(get_api_key_user_async),
+ user: Annotated[User, Depends(get_api_key_user_async)],
+ mock: Annotated[bool, Query()] = True,
+ scenario: Annotated[str, Query(pattern="^(healthy|degraded|offline)$")] = "degraded",
):
@@
async def refresh_status_endpoint(
- user: User = Depends(get_api_key_user_async),
+ user: Annotated[User, Depends(get_api_key_user_async)],
):
@@
async def sync_component_endpoint(
component_id: str,
- user: User = Depends(get_api_key_user_async),
+ user: Annotated[User, Depends(get_api_key_user_async)],
):
@@
async def get_component_logs_endpoint(
component_id: str,
- limit: int = Query(default=50, ge=1, le=500),
- user: User = Depends(get_api_key_user_async),
+ user: Annotated[User, Depends(get_api_key_user_async)],
+ limit: Annotated[int, Query(ge=1, le=500)] = 50,
):
@@
async def get_diagnostics_endpoint(
- user: User = Depends(get_api_key_user_async),
+ user: Annotated[User, Depends(get_api_key_user_async)],
):Also applies to: 310-312, 333-336, 364-368, 391-393
🧰 Tools
🪛 GitHub Check: Ruff and mypy on changed files
[failure] 299-299: ruff (B008)
src/api/v1/status.py:299:18: B008 Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable
🤖 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 `@src/api/v1/status.py` around lines 296 - 300, The endpoint parameters in
get_status_endpoint (and the other endpoints noted) use function call defaults
(Query(...), Depends(...)) which triggers B008; change those parameter
declarations to use typing.Annotated types instead (e.g., replace "mock: bool =
Query(...)" with "mock: Annotated[bool, Query(...)]" and "user: User =
Depends(...)" with "user: Annotated[User, Depends(get_api_key_user_async)]") so
the call is inside the annotation rather than the default value; update imports
to include Annotated from typing (or typing_extensions if needed) and apply the
same pattern to the other functions referenced (the signatures around lines
310-312, 333-336, 364-368, 391-393) using their respective parameter names and
dependency/callables (Query, Depends).
Feature Area
Operations, Observability, Status Page
Problem Description
The frontend team needs a stable API contract to begin implementing the OpenRAG Console Status page before the live readiness checks are available.
Proposed Solution
Add a mock Status API under /api/v1/status that returns component readiness, summary counts, version metadata, and mock actions for OpenRAG Backend, Docling, Langflow, OpenSearch, Embedding Models, and AI Providers.
Implementation Areas
Use Case
As a frontend developer, I can call /api/v1/status and render the Console Status UI using realistic mock data while backend live checks are implemented separately.
Summary by CodeRabbit
Release Notes
New Features
Tests