Skip to content

feat: add status endpoints and mock data for component readiness and version traceability#1571

Open
ricofurtado wants to merge 1 commit into
mainfrom
add-openrag-status-page-for-component-readiness-and-version-traceability
Open

feat: add status endpoints and mock data for component readiness and version traceability#1571
ricofurtado wants to merge 1 commit into
mainfrom
add-openrag-status-page-for-component-readiness-and-version-traceability

Conversation

@ricofurtado
Copy link
Copy Markdown
Collaborator

@ricofurtado ricofurtado commented May 10, 2026

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

  • Add status router
  • Add mock dashboard response
  • Add refresh endpoint
  • Add component sync endpoint
  • Add component logs endpoint
  • Add diagnostics endpoint

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

    • Added component status dashboard API for monitoring system health and individual component status across scenarios (healthy, degraded, offline).
    • Added endpoints for retrieving component logs with pagination and exporting diagnostic data.
    • Enhanced API key authentication to automatically recognize and reuse existing user accounts.
  • Tests

    • Added coverage for API key authentication user handling.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 10, 2026

Walkthrough

This 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.

Changes

Status Dashboard API

Layer / File(s) Summary
Type Definitions and Utilities
src/api/v1/status.py
Type aliases ComponentStatus and OverallStatus defined; now_iso() helper generates UTC ISO-8601 timestamps.
Version and Component Helpers
src/api/v1/status.py
build_version() constructs version metadata dicts; mock_component() assembles complete component payloads with severity, sync timing, uptime, version info, and UI flags.
Dashboard Builder
src/api/v1/status.py
build_mock_status() generates scenario-driven dashboards by selecting per-scenario statuses, building mock components, computing status summaries, and returning environment/deployment metadata.
Authenticated Endpoints
src/api/v1/status.py
Five endpoints: GET /v1/status with scenario control, POST /v1/status/refresh for mock refresh, POST /v1/status/components/{id}/sync for sync result, GET /v1/status/components/{id}/logs with pagination, GET /v1/status/diagnostics for compact diagnostics.
Route Registration
src/app/routes/public_v1.py
Status module imported and all endpoints registered under /v1/status path.

API Key User Resolution

Layer / File(s) Summary
API Key Provider Logic
src/services/user_service.py
ensure_user_row adds special case for provider="api_key": looks up owner by id, falls back to email, updates last_login, returns early if found.
User Service Test
tests/unit/services/test_user_service_bootstrap.py
New test verifies ensure_user_row reuses existing owner by email with api_key provider, preserves original oauth_provider, and prevents duplicate rows.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

enhancement, test

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: adding status endpoints with mock data for component readiness and version tracking.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-openrag-status-page-for-component-readiness-and-version-traceability

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

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

@github-actions github-actions Bot added backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) tests enhancement 🔵 New feature or request and removed enhancement 🔵 New feature or request labels May 10, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/unit/services/test_user_service_bootstrap.py (1)

80-113: ⚡ Quick win

Cover the email-fallback branch explicitly in this test.

Line 100 currently uses uid="owner-subject", which hits get_by_id and may miss regressions in the new get_by_email fallback path. Use a non-matching API-key uid while 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

mock query parameter is currently ignored.

Line 297 accepts mock, but Line 307 always returns mock data. Either remove this parameter for now or reject mock=false explicitly (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

📥 Commits

Reviewing files that changed from the base of the PR and between bfc2378 and c664b5c.

📒 Files selected for processing (4)
  • src/api/v1/status.py
  • src/app/routes/public_v1.py
  • src/services/user_service.py
  • tests/unit/services/test_user_service_bootstrap.py

Comment thread src/api/v1/status.py
Comment on lines +296 to +300
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),
):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 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.py

Repository: 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.py

Repository: 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.py

Repository: 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.py

Repository: 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 -5

Repository: 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 -3

Repository: 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 -30

Repository: langflow-ai/openrag

Length of output: 45


🏁 Script executed:

# Check Python version requirement and linter config
cat pyproject.toml | head -80

Repository: langflow-ai/openrag

Length of output: 2230


🏁 Script executed:

# Specifically look for linting configuration
rg "flake8|ruff|pycodestyle|B008" pyproject.toml -A 3

Repository: 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend 🔷 Issues related to backend services (OpenSearch, Langflow, APIs) enhancement 🔵 New feature or request tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant