From 95622dc4058cb7a3ef49766bc65fdbad6a770888 Mon Sep 17 00:00:00 2001 From: Roland Tannous Date: Thu, 28 May 2026 13:42:46 +0400 Subject: [PATCH] Studio: don't leak exception details in RAG warmup/precache responses CodeQL flagged information exposure through an exception in the /warmup and /reranker/precache endpoints: both returned str(exc) in the JSON body, exposing internal paths and stack details to the client. Keep the full exception in the server-side warning log and return a generic error message ('Failed to load embedder' / 'Failed to download reranker') to the caller instead. The frontend only surfaces the message in a toast, so a generic string is sufficient. --- studio/backend/routes/rag.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/studio/backend/routes/rag.py b/studio/backend/routes/rag.py index 47bd5ae436..c018cac60c 100644 --- a/studio/backend/routes/rag.py +++ b/studio/backend/routes/rag.py @@ -466,8 +466,10 @@ def warmup_rag_embedder( try: embeddings.get_embedder(model_name) except Exception as exc: # noqa: BLE001 + # Log the detailed exception server-side; return a generic message + # so internal paths / stack info aren't exposed to the client. logger.warning("RAG warmup failed for %s: %s", model_name, exc) - return {"ok": False, "model": model_name, "error": str(exc)} + return {"ok": False, "model": model_name, "error": "Failed to load embedder"} return {"ok": True, "model": model_name} @@ -488,12 +490,18 @@ def precache_rag_reranker( try: precache_reranker() except Exception as exc: # noqa: BLE001 + # Detailed exception logged server-side; client gets a generic + # message so internal paths / stack info aren't exposed. logger.warning( "RAG reranker precache failed", model = RAG_RERANKER_MODEL, error = str(exc), ) - return {"ok": False, "model": RAG_RERANKER_MODEL, "error": str(exc)} + return { + "ok": False, + "model": RAG_RERANKER_MODEL, + "error": "Failed to download reranker", + } return {"ok": True, "model": RAG_RERANKER_MODEL}