{"record":{"id":"2cfee1be475af578","repo":"BerriAI/litellm","slug":"invalid-input-anyof-schema-with-only-null-type-is","errorCode":null,"errorMessage":"Invalid input: AnyOf schema with only null type is not supported. Please provide a non-null type.","messagePattern":"Invalid input: AnyOf schema with only null type is not supported\\. Please provide a non-null type\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/common_utils.py","lineNumber":793,"sourceCode":"        raise ValueError(\n            f\"Max depth of {DEFAULT_MAX_RECURSE_DEPTH} exceeded while processing schema. Please check the schema for excessive nesting.\"\n        )\n    \"\"\" Converts null objects within anyOf by removing them and adding nullable to all remaining objects \"\"\"\n    anyof: Final = schema.get(\"anyOf\", None)\n    if anyof is not None:\n        contains_null = False\n        for atype in anyof:\n            if isinstance(atype, dict) and atype.get(\"type\") == \"null\":\n                # remove null type\n                anyof.remove(atype)\n                contains_null = True\n            elif \"type\" not in atype and len(atype) == 0:\n                # Handle empty object case\n                atype[\"type\"] = \"object\"\n\n        if len(anyof) == 0:\n            # Edge case: response schema with only null type present is invalid in Vertex AI\n            raise ValueError(\n                \"Invalid input: AnyOf schema with only null type is not supported. Please provide a non-null type.\"\n            )\n\n        if contains_null:\n            # set all types to nullable following guidance found here: https://cloud.google.com/vertex-ai/generative-ai/docs/samples/generativeaionvertexai-gemini-controlled-generation-response-schema-3#generativeaionvertexai_gemini_controlled_generation_response_schema_3-python\n            # Empty `items: {}` on array branches is left in place; downstream\n            # process_items() converts it to {\"type\": \"object\"}, which Vertex\n            # requires whenever type == \"array\" (even inside anyOf).\n            for atype in anyof:\n                atype[\"nullable\"] = True\n\n    properties: Final = schema.get(\"properties\", None)\n    if properties is not None:\n        for name, value in properties.items():\n            convert_anyof_null_to_nullable(value, depth=depth + 1)\n\n    items: Final = schema.get(\"items\", None)\n    if items is not None:","sourceCodeStart":775,"sourceCodeEnd":811,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/common_utils.py#L775-L811","documentation":"anyOf schema converter guard: every branch of the schema's anyOf was the null type, so after stripping nulls there is no concrete type left to mark nullable — the schema is unusable for Gemini and rejected.","triggerScenarios":"Triggered when an AnyOf schema contains only a null type; a non-null type is required.","commonSituations":"See trigger scenarios.","solutions":["Provide a non-null type in the AnyOf schema.","Remove anyOf entries that only allow null."],"exampleFix":"# replace {\"anyOf\": [{\"type\": \"null\"}]} with a concrete type.","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-14T00:17:10.932Z"}