Dashboard: surface the real compute_fleet error in the response (0.38.2)
The fleet endpoint returned a bare 500, so the error banner only showed "status code 500" with no cause. Wrap the call to log the full traceback server-side and return the exception type, message and originating file:line in the HTTP detail, so the dashboard banner pinpoints the failure for an authenticated user. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
0b95d7d4a2
commit
d399caadc9
@@ -1,7 +1,10 @@
|
||||
"""Dashboard aggregation endpoint (fleet-wide cockpit data)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
import logging
|
||||
import traceback
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from sqlmodel import Session
|
||||
|
||||
from auth import get_current_user
|
||||
@@ -9,6 +12,8 @@ from database import get_session
|
||||
from models.user import User
|
||||
from services import dashboard_service
|
||||
|
||||
logger = logging.getLogger("stackpilot.dashboard")
|
||||
|
||||
router = APIRouter(prefix="/api/dashboard", tags=["dashboard"])
|
||||
|
||||
|
||||
@@ -20,4 +25,15 @@ async def fleet(
|
||||
) -> dict:
|
||||
"""Fleet-wide 'needs attention' list, KPIs and per-host rollup across the
|
||||
local host and every agent — the data behind the operator cockpit."""
|
||||
return await dashboard_service.compute_fleet(session, refresh=refresh)
|
||||
try:
|
||||
return await dashboard_service.compute_fleet(session, refresh=refresh)
|
||||
except Exception as exc: # noqa: BLE001 — surface the real cause for diagnosis
|
||||
logger.exception("compute_fleet failed")
|
||||
# Deepest frame pinpoints where it broke; safe to expose to the
|
||||
# authenticated user and it makes the dashboard error banner actionable.
|
||||
tb = traceback.extract_tb(exc.__traceback__)
|
||||
where = f" at {tb[-1].filename.split('/')[-1]}:{tb[-1].lineno}" if tb else ""
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail=f"{type(exc).__name__}: {exc}{where}",
|
||||
) from exc
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
"""Single source of truth for the StackPilot release version."""
|
||||
|
||||
APP_VERSION = "0.38.1"
|
||||
APP_VERSION = "0.38.2"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "stackpilot-frontend",
|
||||
"private": true,
|
||||
"version": "0.38.1",
|
||||
"version": "0.38.2",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
Reference in New Issue
Block a user