{"record":{"id":"e4fd0878013dfc8d","repo":"BerriAI/litellm","slug":"vertex-location-is-required","errorCode":null,"errorMessage":"vertex_location is required","messagePattern":"vertex_location is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/common_utils.py","lineNumber":329,"sourceCode":"\n\ndef validate_vertex_location(vertex_location: str | None) -> str:\n    \"\"\"\n    Validate a Vertex AI location before interpolating it into a request host or\n    URL path.\n\n    ``vertex_location`` is client-controllable on the proxy (it flows in from the\n    request body), so it must never be trusted verbatim in a URL or an attacker\n    could point the host at their own server and exfiltrate the admin's Google\n    access token. Allow the special ``global`` control plane and otherwise require\n    a lowercase alphanumeric-plus-hyphen token (e.g. ``us``, ``us-central1``,\n    ``eu``), which rejects host injection like ``attacker.example/`` or\n    ``evil.com#``.\n    \"\"\"\n    if vertex_location == \"global\":\n        return vertex_location\n    if vertex_location is None:\n        raise ValueError(\"vertex_location is required\")\n    if not re.match(r\"^[a-z][a-z0-9-]*$\", vertex_location):\n        raise ValueError(\"Invalid vertex_location format\")\n    return vertex_location\n\n\ndef get_vertex_base_url(\n    vertex_location: str | None,\n) -> str:\n    \"\"\"\n    Get the base URL for Vertex AI API calls.\n\n    - ``global`` uses the global control plane host.\n    - Multi-region geographies (e.g. ``us``, ``eu``) use ``aiplatform.{geo}.rep.googleapis.com``.\n    - Regional locations (e.g. ``us-central1``) use ``{region}-aiplatform.googleapis.com``.\n    \"\"\"\n    validated_location: Final = validate_vertex_location(vertex_location)\n    if validated_location == \"global\":\n        return \"https://aiplatform.googleapis.com\"","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/common_utils.py#L311-L347","documentation":"validate_vertex_location guard: the client-supplied vertex_location is None/empty after resolution. Because it is interpolated into the request host (SSRF-sensitive), an explicit error is raised instead of defaulting silently.","triggerScenarios":"Triggered when a Vertex AI call requires vertex_location but none is provided.","commonSituations":"See trigger scenarios.","solutions":["Set VERTEXAI_LOCATION environment variable.","Or pass vertex_location in litellm_params."],"exampleFix":"os.environ[\"VERTEXAI_LOCATION\"] = \"us-central1\"","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"}