BerriAI/litellm · error · HTTPException

Max depth of {DEFAULT_MAX_RECURSE_DEPTH} exceeded while scan

Error message

Max depth of {DEFAULT_MAX_RECURSE_DEPTH} exceeded while scanning vector_store_id values

What it means

Depth guard in the RAG vector_store_id scanner: while recursively walking the ingest payload collecting 'vector_store_id' values, nesting exceeded DEFAULT_MAX_RECURSE_DEPTH. This is a sentinel guard (via _raise_vector_store_scan_depth_exceeded) against pathological or cyclic payload structures.

Source

Thrown at litellm/proxy/rag_endpoints/endpoints.py:42

from litellm.proxy.common_request_processing import ProxyBaseLLMRequestProcessing
from litellm.proxy.common_utils.http_parsing_utils import (
    _read_request_body,
    _safe_get_request_headers,
    get_form_data,
)
from litellm.proxy.vector_store_endpoints.utils import (
    assert_user_can_access_vector_store_id,
)
from litellm.repositories.table_repositories import ManagedVectorStoresRepository

if TYPE_CHECKING:
    from litellm.proxy.utils import PrismaClient

router: Final = APIRouter()


def _raise_vector_store_scan_depth_exceeded() -> None:
    raise HTTPException(
        status_code=400,
        detail={"error": f"Max depth of {DEFAULT_MAX_RECURSE_DEPTH} exceeded while scanning vector_store_id values"},
    )


def _append_payload_to_scan_stack(
    payload_stack: list[tuple[Any, int]],
    value: Any,
    next_depth: int,
) -> None:
    if isinstance(value, dict):
        if next_depth > DEFAULT_MAX_RECURSE_DEPTH:
            _raise_vector_store_scan_depth_exceeded()
        payload_stack.append((value, next_depth))
    elif isinstance(value, list):
        if next_depth > DEFAULT_MAX_RECURSE_DEPTH:
            if any(isinstance(item, (dict, list)) for item in value):
                _raise_vector_store_scan_depth_exceeded()

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Flatten the request payload so vector_store_id values are not nested deeper than the max recurse depth.
  2. Remove circular/deeply nested structures from the request body.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/rag_endpoints/endpoints.py:42 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/5a237d527fffec25. Report an issue: GitHub.