{"record":{"id":"30b6e577187dda02","repo":"mlflow/mlflow","slug":"invalid-config-type-config-model-config","errorCode":null,"errorMessage":"Invalid config type {config.model.config}","messagePattern":"Invalid config type (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"mlflow/gateway/providers/anthropic.py","lineNumber":537,"sourceCode":"        raise NotImplementedError\n\n    @classmethod\n    def model_to_embeddings(cls, resp, config):\n        raise NotImplementedError\n\n\nclass AnthropicProvider(BaseProvider, AnthropicAdapter):\n    DISPLAY_NAME = \"Anthropic\"\n    CONFIG_TYPE = AnthropicConfig\n\n    PASSTHROUGH_PROVIDER_PATHS = {\n        PassthroughAction.ANTHROPIC_MESSAGES: \"messages\",\n    }\n\n    def __init__(self, config: EndpointConfig, enable_tracing: bool = False) -> None:\n        super().__init__(config, enable_tracing=enable_tracing)\n        if config.model.config is None or not isinstance(config.model.config, AnthropicConfig):\n            raise TypeError(f\"Invalid config type {config.model.config}\")\n        self.anthropic_config: AnthropicConfig = config.model.config\n\n    @property\n    def headers(self) -> dict[str, str]:\n        return {\n            \"x-api-key\": self.anthropic_config.anthropic_api_key,\n            \"anthropic-version\": self.anthropic_config.anthropic_version,\n        }\n\n    @property\n    def base_url(self) -> str:\n        return self.anthropic_config.anthropic_api_base\n\n    @property\n    def adapter_class(self) -> type[ProviderAdapter]:\n        return AnthropicAdapter\n\n    def _get_headers(","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/gateway/providers/anthropic.py#L519-L555","documentation":"The AnthropicProvider constructor requires the endpoint's model config to be an AnthropicConfig instance. If config.model.config is None or a different config type (e.g., an OpenAI or Cohere config object), a TypeError is raised at endpoint/adapter initialization time, before any request is made.","triggerScenarios":"Instantiating AnthropicProvider (directly or via the gateway server startup/route wiring) with an EndpointConfig whose model.config is None or of the wrong class.","commonSituations":"A gateway config YAML missing the provider's config block so model.config is None; copying an endpoint config from another provider; programmatic config construction passing the wrong config class; malformed config file not parsed into AnthropicConfig.","solutions":["Fix the gateway endpoint config so the model block includes a valid AnthropicConfig (anthropic_api_key and target_uri for Anthropic).","Use AnthropicProvider only with endpoints whose provider is 'anthropic'; match provider class to the config type.","Validate your config file (mlflow gateway start) and ensure required Anthropic keys are present before server start.","If constructing programmatically, pass AnthropicConfig(...) explicitly instead of None or another provider's config."],"exampleFix":"// before\nprovider = AnthropicProvider(config=openai_endpoint_config)\n// after\nfrom mlflow.gateway.config import AnthropicConfig\nprovider = AnthropicProvider(config=anthropic_endpoint_config)  # config.model.config is AnthropicConfig","handlingStrategy":"type-guard","validationCode":"from mlflow.gateway.config import AnthropicConfig\nif config.model.config is None or not isinstance(config.model.config, AnthropicConfig):\n    raise ValueError(\"Endpoint config must include an AnthropicConfig model config block before creating AnthropicProvider\")","typeGuard":"def is_anthropic_config(config) -> bool:\n    from mlflow.gateway.config import AnthropicConfig\n    return config is not None and isinstance(getattr(config.model, \"config\", None), AnthropicConfig)","tryCatchPattern":"try:\n    provider = AnthropicProvider(config=endpoint_config)\nexcept TypeError as e:\n    if \"Invalid config type\" in str(e):\n        raise ValueError(\n            f\"Endpoint '{endpoint_config.name}' is missing an Anthropic config block; \"\n            \"add anthropic_api_key and anthropic provider settings to your gateway config.\"\n        ) from e\n    raise","preventionTips":["Ensure each gateway endpoint's config YAML includes a complete model config block for its provider.","Match provider class to config type; never reuse one provider's EndpointConfig for another.","Run 'mlflow gateway start' config validation locally before deploying."],"tags":["mlflow-gateway","anthropic","configuration","type-error"],"backgroundTag":"invalid-endpoint-config","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}