{"record":{"id":"475b335679da9aee","repo":"mlflow/mlflow","slug":"invalid-route-type-route-type-475b33","errorCode":null,"errorMessage":"Invalid route type {route_type}","messagePattern":"Invalid route type (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mlflow/gateway/providers/openai.py","lineNumber":268,"sourceCode":"                result_headers.pop(\"authorization\", None)\n                result_headers.pop(\"api-key\", None)\n            result_headers = client_headers | result_headers\n\n        return result_headers\n\n    @property\n    def adapter_class(self):\n        return OpenAIAdapter\n\n    def get_endpoint_url(self, route_type: str) -> str:\n        if route_type == \"llm/v1/chat\":\n            route_path = \"chat/completions\"\n        elif route_type == \"llm/v1/completions\":\n            route_path = \"completions\"\n        elif route_type == \"llm/v1/embeddings\":\n            route_path = \"embeddings\"\n        else:\n            raise ValueError(f\"Invalid route type {route_type}\")\n\n        # Append the route path to the base URL. Note that we cannot simply append the route path\n        # at the end of the base URL because it has query parameters for the Azure OpenAI case.\n        parsed_base_url = urlparse(self.base_url)\n        return urlunparse(parsed_base_url._replace(path=f\"{parsed_base_url.path}/{route_path}\"))\n\n    async def _chat_stream(\n        self, payload: chat.RequestPayload\n    ) -> AsyncIterable[chat.StreamResponsePayload]:\n        from fastapi.encoders import jsonable_encoder\n\n        payload = jsonable_encoder(payload, exclude_none=True)\n        self.check_for_model_field(payload)\n\n        # Inject stream_options.include_usage=true to get usage in final chunk\n        if payload.get(\"stream_options\") is None:\n            payload[\"stream_options\"] = {\"include_usage\": True}\n        elif \"include_usage\" not in payload[\"stream_options\"]:","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/gateway/providers/openai.py#L250-L286","documentation":"OpenAIProvider.get_endpoint_url maps a gateway route type string ('llm/v1/chat', 'llm/v1/completions', 'llm/v1/embeddings') to an OpenAI path. Any other route_type value raises a plain ValueError. It is an internal invariant error, normally not caused by user API calls but by a mis-registered route.","triggerScenarios":"Registering or invoking a gateway route whose route_type string is not one of 'llm/v1/chat', 'llm/v1/completions', 'llm/v1/embeddings' (e.g. 'llm/v1/embedding', 'chat', or an EndpointType enum not converted to its string form).","commonSituations":"Programmatic route registration with a mistyped route type, custom code calling get_endpoint_url directly with an enum instead of its string value, or older/newer MLflow route type names mixed across versions.","solutions":["Use exactly one of the route type strings 'llm/v1/chat', 'llm/v1/completions', or 'llm/v1/embeddings'.","If passing an EndpointType enum, convert it to its string value (str(endpoint_type)) before calling get_endpoint_url.","Create routes via mlflow.gateway.start_server / MlflowException-facing public APIs rather than calling get_endpoint_url directly.","Check the MLflow version; route type naming changed historically, so align code examples with your installed version."],"exampleFix":"// before\nprovider.get_endpoint_url(EndpointType.LLM_V1_CHAT)\n// after\nprovider.get_endpoint_url(str(EndpointType.LLM_V1_CHAT))  # 'llm/v1/chat'","handlingStrategy":"type-guard","validationCode":"VALID = {\"llm/v1/chat\", \"llm/v1/completions\", \"llm/v1/embeddings\"}\nassert route_type in VALID, f\"unsupported route type: {route_type}\"","typeGuard":"def is_valid_route_type(rt) -> bool:\n    return isinstance(rt, str) and rt in {\"llm/v1/chat\", \"llm/v1/completions\", \"llm/v1/embeddings\"}","tryCatchPattern":"try:\n    url = provider.get_endpoint_url(route_type)\nexcept ValueError as e:\n    logging.error(\"Invalid route type: %s\", e)\n    raise","preventionTips":["Use EndpointType constants converted with str() instead of hand-written strings","Register routes via mlflow.gateway public APIs, not provider internals","Pin MLflow docs/examples to your installed version"],"tags":["gateway","openai","route-type","valueerror"],"backgroundTag":"unsupported-route-type","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}