{"record":{"id":"1c069deff4aa06af","repo":"microsoft/semantic-kernel","slug":"invalid-settings-for-onnxgenaitextcompletion-e","errorCode":null,"errorMessage":"Invalid settings for OnnxGenAITextCompletion: {e}","messagePattern":"Invalid settings for OnnxGenAITextCompletion: (.+?)","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/ai/onnx/services/onnx_gen_ai_text_completion.py","lineNumber":55,"sourceCode":"        env_file_encoding: str | None = None,\n    ) -> None:\n        \"\"\"Initializes a new instance of the OnnxGenAITextCompletion class.\n\n        Args:\n            ai_model_path : Local path to the ONNX model Folder.\n            ai_model_id : The ID of the AI model. Defaults to None.\n            env_file_path : Use the environment settings file as a fallback\n                to environment variables.\n            env_file_encoding : The encoding of the environment settings file.\n        \"\"\"\n        try:\n            settings = OnnxGenAISettings(\n                text_model_folder=ai_model_path,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as e:\n            raise ServiceInitializationError(f\"Invalid settings for OnnxGenAITextCompletion: {e}\")\n\n        if settings.text_model_folder is None:\n            raise ServiceInitializationError(\n                \"AI model path is not provided. Please provide the 'ai_model_path' parameter in the constructor. \"\n                \"OR set the 'ONNX_GEN_AI_TEXT_MODEL_FOLDER' environment variable.\"\n            )\n\n        if ai_model_id is None:\n            ai_model_id = settings.text_model_folder\n\n        super().__init__(\n            ai_model_id=ai_model_id,\n            ai_model_path=settings.text_model_folder,\n        )\n\n    @override\n    async def _inner_get_text_contents(\n        self,","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/ai/onnx/services/onnx_gen_ai_text_completion.py#L37-L73","documentation":"Raised by the OnnxGenAITextCompletion constructor when OnnxGenAISettings(...) raises a Pydantic ValidationError during settings construction. The original error is embedded in the message via f-string. Note this error does NOT chain the exception ('from e' is absent), so the traceback context may be less detailed than the chat-completion equivalent (error 1128).","triggerScenarios":"Constructing OnnxGenAITextCompletion with settings that fail Pydantic validation — corrupt .env file, unexpected types for ONNX_GEN_AI_TEXT_MODEL_FOLDER, or env_file_encoding mismatch.","commonSituations":"Malformed .env file entries; env_file_path pointing at a non-existent file; environment variable with encoding issues; running in a container where env vars are set to non-string types.","solutions":["Read the full message which embeds the ValidationError string","Fix the offending .env entry or environment variable","Verify env_file_path and env_file_encoding are correct"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"from pydantic import ValidationError\nfrom semantic_kernel.connectors.ai.onnx.onnx_gen_ai_settings import OnnxGenAISettings\n\ntry:\n    test = OnnxGenAISettings(text_model_folder='/path/to/model')\nexcept ValidationError as e:\n    print(f'OnnxGenAI text settings invalid: {e}')\n    raise\n\ntext = OnnxGenAITextCompletion(ai_model_path='/path/to/model')","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions.service_exceptions import ServiceInitializationError\n\ntry:\n    text = OnnxGenAITextCompletion()\nexcept ServiceInitializationError as e:\n    logger.error('OnnxGenAI text settings error: %s', e)\n    raise","preventionTips":["Pre-validate OnnxGenAISettings before constructing the text service","Ensure .env entries are clean key=value pairs","Verify env_file_path and env_file_encoding at startup"],"tags":["onnx","configuration","settings-validation","initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}