{"record":{"id":"0ad9b6b2c4d87e3f","repo":"BerriAI/litellm","slug":"expected-project-id-to-be-a-str-but-got-type-proj","errorCode":null,"errorMessage":"Expected project_id to be a str but got {type(project_id)}","messagePattern":"Expected project_id to be a str but got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"litellm/llms/vertex_ai/vertex_llm_base.py","lineNumber":196,"sourceCode":"                    scopes=[\"https://www.googleapis.com/auth/cloud-platform\"],\n                )\n\n            if project_id is None:\n                project_id = getattr(creds, \"project_id\", None)\n        else:\n            creds, creds_project_id = self._credentials_from_default_auth(\n                scopes=[\"https://www.googleapis.com/auth/cloud-platform\"]\n            )\n            if project_id is None:\n                project_id = creds_project_id\n\n        self.refresh_auth(creds)\n\n        if not project_id:\n            raise ValueError(\"Could not resolve project_id\")\n\n        if not isinstance(project_id, str):\n            raise TypeError(f\"Expected project_id to be a str but got {type(project_id)}\")\n\n        return creds, project_id\n\n    # Google Auth Helpers -- extracted for mocking purposes in tests\n    def _credentials_from_identity_pool(self, json_obj, scopes):\n        try:\n            from google.auth import identity_pool\n        except ImportError:\n            raise ImportError(GOOGLE_IMPORT_ERROR_MESSAGE)\n\n        creds = identity_pool.Credentials.from_info(json_obj)\n        if scopes and hasattr(creds, \"requires_scopes\") and creds.requires_scopes:\n            creds = creds.with_scopes(scopes)\n        return creds\n\n    def _credentials_from_pluggable(self, json_obj, scopes):\n        try:\n            from google.auth import pluggable","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/vertex_ai/vertex_llm_base.py#L178-L214","documentation":"Type guard after project_id resolution: a project_id was found but is not a string (e.g. an int or object from a malformed credential file), which would break URL construction. The actual type is included.","triggerScenarios":"Thrown at litellm/llms/vertex_ai/vertex_llm_base.py:196 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass project_id as a string; convert the value (see its type in the error) with str() or fix the source providing it.","Check that VERTEXAI_PROJECT / vertex_project is not being set to a non-string object."],"exampleFix":null,"handlingStrategy":"type-guard","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"}