{"record":{"id":"3829b752bbde83cf","repo":"BerriAI/litellm","slug":"max-depth-of-default-max-recurse-depth-exceeded","errorCode":null,"errorMessage":"Max depth of {DEFAULT_MAX_RECURSE_DEPTH} exceeded while processing schema.","messagePattern":"Max depth of (.+?) exceeded while processing schema\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/common_utils.py","lineNumber":512,"sourceCode":"def _check_text_in_content(parts: list[PartType]) -> bool:\n    \"\"\"\n    check that user_content has 'text' parameter.\n        - Known Vertex Error: Unable to submit request because it must have a text parameter.\n        - 'text' param needs to be present (empty strings are valid)\n        - Relevant Issue: https://github.com/BerriAI/litellm/issues/5515\n    \"\"\"\n    has_text_param = False\n    for part in parts:\n        if \"text\" in part and part.get(\"text\") is not None:\n            has_text_param = True\n\n    return has_text_param\n\n\ndef _fix_enum_empty_strings(schema, depth=0):\n    \"\"\"Fix empty strings in enum values by replacing them with None. Gemini doesn't accept empty strings in enums.\"\"\"\n    if depth > DEFAULT_MAX_RECURSE_DEPTH:\n        raise ValueError(f\"Max depth of {DEFAULT_MAX_RECURSE_DEPTH} exceeded while processing schema.\")\n\n    if \"enum\" in schema and isinstance(schema[\"enum\"], list):\n        schema[\"enum\"] = [None if value == \"\" else value for value in schema[\"enum\"]]\n\n    # Reuse existing recursion pattern from convert_anyof_null_to_nullable\n    properties: Final = schema.get(\"properties\", None)\n    if properties is not None:\n        for _, value in properties.items():\n            _fix_enum_empty_strings(value, depth=depth + 1)\n\n    items: Final = schema.get(\"items\", None)\n    if items is not None:\n        _fix_enum_empty_strings(items, depth=depth + 1)\n\n\ndef _fix_enum_types(schema, depth=0):\n    \"\"\"Remove `enum` fields when the schema type is not string.\n","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/common_utils.py#L494-L530","documentation":"Recursive schema sanitizer guard: _fix_enum_empty_strings (or a sibling processor) exceeded DEFAULT_MAX_RECURSE_DEPTH while walking the tool/response_schema, protecting against pathological or cyclic nested schemas.","triggerScenarios":"Triggered when schema processing exceeds DEFAULT_MAX_RECURSE_DEPTH due to excessive nesting.","commonSituations":"See trigger scenarios.","solutions":["Reduce nesting depth of the schema.","Flatten or simplify the JSON schema passed in the request."],"exampleFix":"# remove deeply nested $ref/anyOf chains from the response schema.","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}