{"record":{"id":"608db7a396a07e82","repo":"microsoft/semantic-kernel","slug":"invalid-settings-exc-608db7","errorCode":null,"errorMessage":"Invalid settings: {exc}","messagePattern":"Invalid settings: (.+?)","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/open_ai/services/azure_text_to_image.py","lineNumber":77,"sourceCode":"            async_client: An existing client to use. (Optional)\n            env_file_path: Use the environment settings file as a fallback to\n                environment variables. (Optional)\n            env_file_encoding: The encoding of the environment settings file. (Optional)\n            credential: The credential to use for authentication. (Optional)\n        \"\"\"\n        try:\n            azure_openai_settings = AzureOpenAISettings(\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n                api_key=api_key,\n                text_to_image_deployment_name=deployment_name,\n                endpoint=endpoint,\n                base_url=base_url,\n                api_version=api_version,\n                token_endpoint=token_endpoint,\n            )\n        except ValidationError as exc:\n            raise ServiceInitializationError(f\"Invalid settings: {exc}\") from exc\n        if not azure_openai_settings.text_to_image_deployment_name:\n            raise ServiceInitializationError(\"The Azure OpenAI text to image deployment name is required.\")\n\n        super().__init__(\n            deployment_name=azure_openai_settings.text_to_image_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_TO_IMAGE,\n            client=async_client,\n            credential=credential,\n        )","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/open_ai/services/azure_text_to_image.py#L59-L95","documentation":"Raised by AzureTextToImage.__init__ when AzureOpenAISettings construction throws a pydantic ValidationError. The settings model validates endpoint (HttpsUrl), base_url (Url), api_key (SecretStr), api_version (str). Any field value that fails type coercion produces this wrapped error.","triggerScenarios":"Constructing AzureTextToImage with a non-HTTPS endpoint, a malformed base_url, or an invalid AZURE_OPENAI_ENDPOINT environment variable. Passing api_version as a non-string type also triggers it.","commonSituations":"Passing endpoint='http://...' (HttpsUrl rejects http); bare hostname without scheme; .env file with corrupted endpoint value; CI environment with an improperly set secret.","solutions":["Inspect the chained ValidationError for the specific failing field and constraint.","Ensure endpoint is a valid https:// URL ending in openai.azure.com.","Verify .env file syntax and environment variable formatting.","Pass api_version as a string."],"exampleFix":"# before\nservice = AzureTextToImage(\n    deployment_name='dall-e-3',\n    endpoint='http://myresource.openai.azure.com',\n    api_key='...',\n)\n# after\nservice = AzureTextToImage(\n    deployment_name='dall-e-3',\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 = AzureTextToImage(\n        deployment_name='dall-e-3',\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":["Always use https:// for Azure OpenAI endpoints.","Validate endpoint URL format before constructing the service.","Read the chained ValidationError (__cause__) for the specific field that failed.","Verify .env file syntax and environment variable formatting."],"tags":["azure-openai","text-to-image","pydantic","settings-validation"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}