{"record":{"id":"befce198d6cc057d","repo":"microsoft/semantic-kernel","slug":"invalid-settings-ex","errorCode":null,"errorMessage":"Invalid settings: {ex}","messagePattern":"Invalid settings: (.+?)","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/open_ai/services/azure_text_completion.py","lineNumber":87,"sourceCode":"            default_headers: The default headers mapping of string keys to\n                string values for HTTP requests. (Optional)\n            async_client (Optional[AsyncAzureOpenAI]): An existing client to use. (Optional)\n            env_file_path (str | None): Use the environment settings file as a fallback to\n                environment variables. (Optional)\n            credential (TokenCredential): The credential to use for authentication. (Optional)\n        \"\"\"\n        try:\n            azure_openai_settings = AzureOpenAISettings(\n                env_file_path=env_file_path,\n                text_deployment_name=deployment_name,\n                endpoint=endpoint,\n                base_url=base_url,\n                api_key=api_key,\n                api_version=api_version,\n                token_endpoint=token_endpoint,\n            )\n        except ValidationError as ex:\n            raise ServiceInitializationError(f\"Invalid settings: {ex}\") from ex\n        if not azure_openai_settings.text_deployment_name:\n            raise ServiceInitializationError(\"The Azure Text deployment name is required.\")\n\n        super().__init__(\n            deployment_name=azure_openai_settings.text_deployment_name,\n            endpoint=azure_openai_settings.endpoint,\n            base_url=azure_openai_settings.base_url,\n            api_version=azure_openai_settings.api_version,\n            service_id=service_id,\n            api_key=azure_openai_settings.api_key.get_secret_value() if azure_openai_settings.api_key else None,\n            ad_token=ad_token,\n            ad_token_provider=ad_token_provider,\n            token_endpoint=azure_openai_settings.token_endpoint,\n            default_headers=default_headers,\n            ai_model_type=OpenAIModelTypes.TEXT,\n            client=async_client,\n            credential=credential,\n        )","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/open_ai/services/azure_text_completion.py#L69-L105","documentation":"Raised by AzureTextCompletion.__init__ when AzureOpenAISettings construction throws a pydantic ValidationError. Note: AzureTextCompletion itself is decorated @deprecated (all Azure OpenAI text completion models have retired). The settings model validates endpoint as HttpsUrl, base_url as Url, api_key as SecretStr, and api_version as str. Any field failing coercion produces the wrapped error.","triggerScenarios":"Constructing the deprecated AzureTextCompletion with an endpoint that is not a valid HTTPS URL, a malformed base_url value, or an AZURE_OPENAI_ENDPOINT env var containing an invalid URL. Also triggered by passing api_version as a non-string type.","commonSituations":"Still using AzureTextCompletion after Azure retired all text completion models (should migrate to AzureChatCompletion); passing 'http://...' for endpoint; .env file with a broken endpoint value; version upgrade where field types became stricter (str to HttpsUrl).","solutions":["Migrate from AzureTextCompletion to AzureChatCompletion — Azure OpenAI text completion models are retired and this class is deprecated for removal after 2026-01-01.","If you must use it, inspect the chained ValidationError for the specific failing field.","Ensure endpoint is a full https:// URL (e.g. 'https://myresource.openai.azure.com').","Pass api_version as a string."],"exampleFix":"# before (deprecated class with invalid endpoint)\nservice = AzureTextCompletion(\n    deployment_name='text-davinci-003',\n    endpoint='myresource.openai.azure.com',\n    api_key='...',\n)\n# after (migrate to chat completion with valid endpoint)\nservice = AzureChatCompletion(\n    deployment_name='gpt-4o',\n    endpoint='https://myresource.openai.azure.com',\n    api_key='...',\n)","handlingStrategy":"try-catch","validationCode":"from urllib.parse import urlparse\n\ndef validate_azure_endpoint(endpoint: str | None) -> str:\n    if endpoint is None:\n        raise ValueError('endpoint is required')\n    parsed = urlparse(endpoint)\n    if parsed.scheme != 'https':\n        raise ValueError(f'endpoint must use https:// scheme, got {parsed.scheme}://')\n    return endpoint\n\nvalidate_azure_endpoint(os.environ.get('AZURE_OPENAI_ENDPOINT'))","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError\n\ntry:\n    service = AzureTextCompletion(\n        deployment_name='text-davinci-003',\n        endpoint='https://myresource.openai.azure.com',\n        api_key='...',\n    )\nexcept ServiceInitializationError as e:\n    cause = e.__cause__\n    if cause:\n        print(f'Settings validation failed: {cause}')\n    raise","preventionTips":["Migrate from AzureTextCompletion to AzureChatCompletion — text completion models are retired and the class is deprecated.","Always use https:// for Azure endpoints.","Read the chained ValidationError (__cause__) for the specific field that failed.","Validate endpoint URL format before constructing the service."],"tags":["azure-openai","text-completion","deprecated","pydantic","settings-validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}