feat: add proper HTTP status codes to all API error responses
- 217 error returns across 18 route files + api.py now use JSONResponse with appropriate HTTP status codes instead of returning HTTP 200 - Status code distribution: 500 (121), 400 (39), 503 (28), 404 (24), 409 (3), 502 (2) - Fixed language.py tuple-return bug (was serializing as JSON array) - Fixed bare except clauses in bipolar_mode.py and voice.py - Body-level error schemas preserved (status/error + success/error patterns) so web UI continues working without changes - chat.py (SSE) unchanged: errors sent within stream protocol - All 170 tests pass
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Core routes: index, logs, prompts, status, conversation."""
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi.responses import FileResponse
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
import globals
|
||||
from server_manager import server_manager
|
||||
from utils.conversation_history import conversation_history
|
||||
@@ -26,7 +26,7 @@ def get_logs():
|
||||
last_100 = lines[-100:] if len(lines) >= 100 else lines
|
||||
return "".join(last_100)
|
||||
except Exception as e:
|
||||
return f"Error reading log file: {e}"
|
||||
return JSONResponse(status_code=500, content={"status": "error", "message": f"Error reading log file: {e}"})
|
||||
|
||||
|
||||
@router.get("/prompt")
|
||||
|
||||
Reference in New Issue
Block a user