{"record":{"id":"40a0f1006b1c63cf","repo":"microsoft/semantic-kernel","slug":"failed-to-validate-vertex-ai-settings-e-40a0f1","errorCode":null,"errorMessage":"Failed to validate Vertex AI settings: {e}","messagePattern":"Failed to validate Vertex AI settings: (.+?)","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/google/vertex_ai/services/vertex_ai_text_completion.py","lineNumber":75,"sourceCode":"\n        Args:\n            project_id (str): The Google Cloud project ID.\n            region (str): The Google Cloud region.\n            gemini_model_id (str): The Gemini model ID.\n            service_id (str): The Vertex AI service ID.\n            env_file_path (str): The path to the environment file.\n            env_file_encoding (str): The encoding of the environment file.\n        \"\"\"\n        try:\n            vertex_ai_settings = VertexAISettings(\n                project_id=project_id,\n                region=region,\n                gemini_model_id=gemini_model_id,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as e:\n            raise ServiceInitializationError(f\"Failed to validate Vertex AI settings: {e}\") from e\n        if not vertex_ai_settings.gemini_model_id:\n            raise ServiceInitializationError(\"The Vertex AI Gemini model ID is required.\")\n\n        super().__init__(\n            ai_model_id=vertex_ai_settings.gemini_model_id,\n            service_id=service_id or vertex_ai_settings.gemini_model_id,\n            service_settings=vertex_ai_settings,\n        )\n\n    # region Overriding base class methods\n\n    # Override from AIServiceClientBase\n    @override\n    def get_prompt_execution_settings_class(self) -> type[\"PromptExecutionSettings\"]:\n        return VertexAITextPromptExecutionSettings\n\n    @override\n    @trace_text_completion(VertexAIBase.MODEL_PROVIDER_NAME)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/google/vertex_ai/services/vertex_ai_text_completion.py#L57-L93","documentation":"Raised by VertexAITextCompletion.__init__ when VertexAISettings construction throws a pydantic ValidationError. The error wraps the validation detail into a ServiceInitializationError so text-completion service initialization fails fast with the underlying reason (project_id/region/env).","triggerScenarios":"Instantiating VertexAITextCompletion with missing/malformed project_id, region, or env configuration. Same root causes as the chat variant but on the text-completion constructor.","commonSituations":"Missing VERTEX_AI_PROJECT or region env var. Bad .env path/encoding. Credentials not configured for the text-completion flow.","solutions":["Inspect the embedded {e} to find the failing field(s).","Provide project_id and region explicitly or via env/ .env.","Confirm env_file_path is correct and the file has the expected keys."],"exampleFix":"# before\nsvc = VertexAITextCompletion()\n# after\nsvc = VertexAITextCompletion(project_id='my-project', region='us-central1', gemini_model_id='gemini-1.5-pro')","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.ai.google.vertex_ai.vertex_ai_settings import VertexAISettings\ntry:\n    s = VertexAISettings()\nexcept Exception as e:\n    print('config invalid:', e)","typeGuard":null,"tryCatchPattern":"try:\n    svc = VertexAITextCompletion(project_id=..., region=..., gemini_model_id=...)\nexcept ServiceInitializationError as e:\n    raise","preventionTips":["Configure project_id and region before constructing the text-completion service.","Validate env / .env contents in isolation.","Confirm credentials are set up for Vertex AI."],"tags":["vertex-ai","configuration","settings","initialization","text-completion"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}