Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(vector-stores): re-raise HTTPException from get_vector_store_info; allowlist recursion

user4d92bc8b860d
diff --git a/litellm/proxy/vector_store_endpoints/management_endpoints.py b/litellm/proxy/vector_store_endpoints/management_endpoints.py
index 48d08a35d7c..99a2085bfcd 100644
--- a/litellm/proxy/vector_store_endpoints/management_endpoints.py
+++ b/litellm/proxy/vector_store_endpoints/management_endpoints.py
@@ -43,7 +43,10 @@ router = APIRouter()
_LITELLM_PARAMS_MASKER = SensitiveDataMasker()
-def _redact_sensitive_litellm_params(litellm_params: Any) -> Any:
+_REDACT_LITELLM_PARAMS_MAX_DEPTH = 10
+
+
+def _redact_sensitive_litellm_params(litellm_params: Any, _depth: int = 0) -> Any:
"""
Replace credential-bearing values in ``litellm_params`` with
``REDACTED_BY_LITELM`` while preserving non-secret keys (``api_base``,
@@ -58,7 +61,13 @@ def _redact_sensitive_litellm_params(litellm_params: Any) -> Any:
fails, return the redaction sentinel rather than echo the value
back verbatim.
* Anything else, or ``None`` — passed through.
+
+ Recursion depth is bounded by ``_REDACT_LITELLM_PARAMS_MAX_DEPTH`` —
+ matching the convention of other allowlisted recursive helpers in the
+ repo (see ``tests/code_coverage_tests/recursive_detector.py``).
"""
+ if _depth >= _REDACT_LITELLM_PARAMS_MAX_DEPTH:
+ return REDACTED_BY_LITELM_STRING
if litellm_params is None:
return None
if isinstance(litellm_params, str):
@@ -66,7 +75,7 @@ def _redact_sensitive_litellm_params(litellm_params: Any) -> Any:
parsed = json.loads(litellm_params)
except (TypeError, ValueError):
return REDACTED_BY_LITELM_STRING
- return json.dumps(_redact_sensitive_litellm_params(parsed))
+ return json.dumps(_redact_sensitive_litellm_params(parsed, _depth + 1))
if not isinstance(litellm_params, dict):
return litellm_params
out: Dict[str, Any] = {}
@@ -74,7 +83,7 @@ def _redact_sensitive_litellm_params(litellm_params: Any) -> Any:
if _LITELLM_PARAMS_MASKER.is_sensitive_key(k):
out[k] = REDACTED_BY_LITELM_STRING
elif isinstance(v, dict):
- out[k] = _redact_sensitive_litellm_params(v)
+ out[k] = _redact_sensitive_litellm_params(v, _depth + 1)
else:
out[k] = v
return out
@@ -807,6 +816,10 @@ async def get_vector_store_info(
vector_store_dict["litellm_params"]
)
return {"vector_store": vector_store_dict}
+ except HTTPException:
+ # Preserve 403/404 from the access-control / not-found checks above;
+ # the catch-all below would otherwise rewrite them as 500.
+ raise
except Exception as e:
verbose_proxy_logger.exception(f"Error getting vector store info: {str(e)}")
raise HTTPException(status_code=500, detail=str(e))
diff --git a/tests/code_coverage_tests/recursive_detector.py b/tests/code_coverage_tests/recursive_detector.py
index fc9c99f6afc..07af2735dfe 100644
--- a/tests/code_coverage_tests/recursive_detector.py
+++ b/tests/code_coverage_tests/recursive_detector.py
@@ -46,6 +46,7 @@ IGNORE_FUNCTIONS = [
"dict", # max depth set. _LiteLLMParamsDictView.dict() calls builtin dict(), not itself.
"_read_image_bytes", # max depth set.
"_get_masked_values", # max depth set (default 20) to prevent infinite recursion while masking nested sensitive config dicts.
+ "_redact_sensitive_litellm_params", # max depth set (default 10).
]