You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(stats): do not hide metadata query failures as successful zero counts #49
GET /admin/api/stats turns relational query failures into successful zero counts. Missing/broken application metadata is indistinguishable from a healthy, empty index in the dashboard and API.
Related reproducer: #45. Fixing selected-database access does not eliminate the need to distinguish failed queries from legitimate empty results.
Observed evidence
At source revision 41ec093a745f1c0277893dc8f758b96b216c970f, an isolated full-PostgreSQL deployment initialized its PostgreSQL schema and healthy pgvector backend, but legacy metadata queries opened an empty SQLite database.
Authenticated /admin/api/repos returned HTTP 500 with no such table: git_repositories logged. Indexing and polling also logged missing-table failures.
In the same state, authenticated GET /admin/api/stats returned HTTP 200:
Distinguish genuine zero counts from failed/unavailable counts.
Required relational query failures should produce the API's explicit error response, or a deliberately documented degraded result with unavailable counts and visible error state; do not silently substitute zero.
Log useful, sanitized diagnostics and make the failure visible to the dashboard.
Do not report the entire application as healthy just because its vector backend is healthy.
Acceptance checks
A healthy, empty database still returns successful zero counts.
Missing-table and database-unavailable/query-failure tests do not return success-shaped zero counts.
In app/api/routers/settings.py, the internal _count() helper catches all query exceptions and returns 0. When the relational database is broken or missing tables, GET /admin/api/stats returns HTTP 200 with all zero counts and reports vector_db_status: "Healthy", masking database faults.
3. Implementation Plan
Refactor _count() in settings.py to distinguish between a successful zero count and an execution failure.
On database failure, return an explicit error response (HTTP 500) or a structured degraded response where unavailable counts are null and a failure indicator is present.
Ensure vector_db_status does not cause the entire service to report healthy if relational metadata is failing.
4. Acceptance Criteria
Healthy, empty databases return successful zero counts.
Relational query failures return an error status or explicit degraded indicators rather than false zero counts.
Activity
spelech commentedon Oct 27, 2026
Triage & Implementation Brief
1. Scope & Effort
2. Root Cause & Context
In
app/api/routers/settings.py, the internal_count()helper catches all query exceptions and returns0. When the relational database is broken or missing tables,GET /admin/api/statsreturns HTTP 200 with all zero counts and reportsvector_db_status: "Healthy", masking database faults.3. Implementation Plan
_count()insettings.pyto distinguish between a successful zero count and an execution failure.nulland a failure indicator is present.vector_db_statusdoes not cause the entire service to report healthy if relational metadata is failing.4. Acceptance Criteria
/admin/api/stats.google-labs-jules commentedon Oct 27, 2026
Jules is on it. When finished, you will see another comment and be able to review a PR.
google-labs-jules commentedon Oct 27, 2026
Ready for a review! A PR has been created.