{"record":{"id":"d2f54b01d25bce46","repo":"mlflow/mlflow","slug":"unexpected-config-type-config-model-config-d2f54b","errorCode":null,"errorMessage":"Unexpected config type {config.model.config}","messagePattern":"Unexpected config type (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"mlflow/gateway/providers/mosaicml.py","lineNumber":26,"sourceCode":"from mlflow.gateway.exceptions import AIGatewayException\nfrom mlflow.gateway.providers.base import BaseProvider\nfrom mlflow.gateway.providers.utils import rename_payload_keys, send_request\nfrom mlflow.gateway.schemas import chat, completions, embeddings\n\n\nclass MosaicMLProvider(BaseProvider):\n    DISPLAY_NAME = \"MosaicML\"\n    CONFIG_TYPE = MosaicMLConfig\n\n    def __init__(self, config: EndpointConfig, enable_tracing: bool = False) -> None:\n        super().__init__(config, enable_tracing=enable_tracing)\n        warnings.warn(\n            \"MosaicML provider is deprecated and will be removed in a future MLflow version.\",\n            category=FutureWarning,\n            stacklevel=2,\n        )\n        if config.model.config is None or not isinstance(config.model.config, MosaicMLConfig):\n            raise TypeError(f\"Unexpected config type {config.model.config}\")\n        self.mosaicml_config: MosaicMLConfig = config.model.config\n\n    async def _request(self, model: str, payload: dict[str, Any]) -> dict[str, Any]:\n        headers = {\"Authorization\": f\"{self.mosaicml_config.mosaicml_api_key}\"}\n        return await send_request(\n            headers=headers,\n            base_url=self.mosaicml_config.mosaicml_api_base\n            or \"https://models.hosted-on.mosaicml.hosting\",\n            path=model + \"/v1/predict\",\n            payload=payload,\n        )\n\n    # NB: as this parser performs no blocking operations, we are intentionally not defining it\n    # as async due to the overhead of spawning an additional thread if we did.\n    @staticmethod\n    def _parse_chat_messages_to_prompt(messages: list[chat.RequestMessage]) -> str:\n        \"\"\"\n        This parser is based on the format described in","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/gateway/providers/mosaicml.py#L8-L44","documentation":"The MosaicML provider's constructor requires config.model.config to be a MosaicMLConfig instance; if it is None or another type a TypeError is raised at provider instantiation time. This is a programmer/config-shape guard: the provider cannot build its request headers (API key) without the typed config.","triggerScenarios":"Constructing the MosaicML provider with an EndpointConfig whose model.config is None or holds a plain dict / wrong config class instead of MosaicMLConfig.","commonSituations":"Hand-building provider instances in tests or custom code and forgetting to nest a MosaicMLConfig; loading a route config from YAML where the mosaicml config block is missing; passing OpenAIConfig or AnyscaleConfig to a mosaicml route.","solutions":["Wrap the model config in MosaicMLConfig, e.g. MosaicMLConfig(mosaicml_api_key=os.environ[\"MOSAICML_API_KEY\"]), and set it as config.model.config","Validate your route config file so the endpoint's model config block matches the mosaicml schema before instantiating the provider","Note the provider is deprecated (FutureWarning) — migrate the route to another provider (e.g. openai-compatible) to avoid maintaining it"],"exampleFix":"// before\nconfig.model.config = {\"mosaicml_api_key\": \"...\"}\n// after\nfrom mlflow.gateway.config import MosaicMLConfig\nconfig.model.config = MosaicMLConfig(mosaicml_api_key=\"...\")","handlingStrategy":"validation","validationCode":"from mlflow.gateway.config import MosaicMLConfig\nif not isinstance(config.model.config, MosaicMLConfig):\n    raise ValueError(\"route model.config must be a MosaicMLConfig\")","typeGuard":"def is_mosaicml_config(cfg) -> bool:\n    from mlflow.gateway.config import MosaicMLConfig\n    return isinstance(cfg, MosaicMLConfig)","tryCatchPattern":null,"preventionTips":["Always build route configs through mlflow.gateway config helpers, not raw dicts","Validate config YAML against the provider schema before deployment","Remember MosaicML provider is deprecated — plan migration to another provider"],"tags":["config","typeerror","mosaicml","provider-init"],"backgroundTag":"invalid-provider-config","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}