Skip to content

Commit 69cb3be

Browse files
JiahaoJiahao
authored andcommitted
fix: sanitize internal error details in global 500 handler
The catch-all exception handler was returning str(exc) directly in the API response, leaking internal filesystem paths, backend error messages, and configuration details to clients (information disclosure). - Replace str(exc) with a static "Internal server error" message - Upgrade logger.warning to logger.exception so the full traceback is preserved in server logs for debugging Closes #1233
1 parent b174deb commit 69cb3be

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

openviking/server/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ async def openviking_error_handler(request: Request, exc: OpenVikingError):
186186
# Catch-all for unhandled exceptions so clients always get JSON
187187
@app.exception_handler(Exception)
188188
async def general_error_handler(request: Request, exc: Exception):
189-
logger.warning("Unhandled exception: %s", exc)
189+
logger.exception("Unhandled exception")
190190
return JSONResponse(
191191
status_code=500,
192192
content=Response(
193193
status="error",
194194
error=ErrorInfo(
195195
code="INTERNAL",
196-
message=str(exc),
196+
message="Internal server error",
197197
),
198198
).model_dump(),
199199
)

0 commit comments

Comments
 (0)