{"record":{"id":"be7e9ee8e3fd3f28","repo":"microsoft/semantic-kernel","slug":"missing-required-configuration-field-s-joi","errorCode":null,"errorMessage":"Missing required configuration field(s): {', '.join(missing_params)}","messagePattern":"Missing required configuration field\\(s\\): (.+?)","errorType":"exception","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/copilot_studio/copilot_studio_agent.py","lineNumber":391,"sourceCode":"                tenant_id=tenant_id,\n                environment_id=environment_id,\n                agent_identifier=agent_identifier,\n                cloud=cloud,\n                type=copilot_agent_type,\n                custom_power_platform_cloud=custom_power_platform_cloud,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n                client_secret=client_secret,\n                client_certificate=client_certificate,\n                user_assertion=user_assertion,\n                auth_mode=auth_mode,\n            )\n        except ValidationError as exc:\n            raise AgentInitializationException(f\"Failed to create Copilot Studio Agent settings: {exc}\") from exc\n\n        missing_params = [name for name in (\"app_client_id\", \"tenant_id\") if not getattr(connection_settings, name)]\n        if missing_params:\n            raise AgentInitializationException(f\"Missing required configuration field(s): {', '.join(missing_params)}\")\n\n        cache_file = environ.get(\"TOKEN_CACHE_PATH_INTERACTIVE\") or path.join(\n            path.dirname(__file__), \"bin\", \"token_cache_interactive.bin\"\n        )\n\n        token = _CopilotStudioAgentTokenFactory(\n            settings=connection_settings,\n            cache_path=cache_file,\n            mode=connection_settings.auth_mode,\n            client_secret=connection_settings.client_secret.get_secret_value()\n            if connection_settings.client_secret\n            else None,\n            client_certificate=Path(client_certificate) if client_certificate else None,\n            user_assertion=user_assertion,\n        ).acquire()\n\n        return CopilotClient(connection_settings, token)\n","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/copilot_studio/copilot_studio_agent.py#L373-L409","documentation":"Raised by CopilotStudioAgent.create_client() after settings are successfully constructed but app_client_id or tenant_id (or both) are empty/falsy. The code explicitly checks these two fields because they are mandatory for MSAL authentication and CopilotClient construction, yet the settings model itself may allow them as optional (loaded from env). It is an AgentInitializationException naming the missing field(s).","triggerScenarios":"Calling create_client() without app_client_id/tenant_id arguments and without corresponding values in the .env file or environment variables. The settings object is built (no ValidationError) but the fields resolve to None or empty string.","commonSituations":"Missing APP_CLIENT_ID / TENANT_ID environment variables; .env file not found or misnamed (wrong env_file_path); values present but commented out; running in a fresh environment without copying the .env template.","solutions":["Set APP_CLIENT_ID and TENANT_ID in the environment or .env file before calling create_client().","Pass them explicitly: create_client(app_client_id=..., tenant_id=...).","Verify env_file_path points to the correct .env file and that values are uncommented.","Use a settings preload step to check values before creating the client."],"exampleFix":"# before\nclient = CopilotStudioAgent.create_client()  # no env vars set\n\n# after\nclient = CopilotStudioAgent.create_client(\n    app_client_id=os.environ[\"APP_CLIENT_ID\"],\n    tenant_id=os.environ[\"TENANT_ID\"],\n)","handlingStrategy":"validation","validationCode":"missing = [f for f in (\"app_client_id\", \"tenant_id\") if not locals().get(f)]\nif missing:\n    raise ValueError(f\"Missing required config: {missing}\")\nclient = CopilotStudioAgent.create_client(app_client_id=app_client_id, tenant_id=tenant_id)","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions.agent_exceptions import AgentInitializationException\n\ntry:\n    client = CopilotStudioAgent.create_client()\nexcept AgentInitializationException as exc:\n    if \"Missing required configuration\" in str(exc):\n        # load from alternative source or prompt user\n        ...\n    raise","preventionTips":["Always set APP_CLIENT_ID and TENANT_ID in the environment or .env file.","Pass them explicitly to create_client() to fail fast with clear errors.","Validate env vars at application startup before any agent construction."],"tags":["configuration","missing-params","copilot-studio","initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}