{"record":{"id":"0330ae9fc0d3b45d","repo":"BerriAI/litellm","slug":"qualityrouter-no-user-message-and-no-default-mode","errorCode":null,"errorMessage":"QualityRouter: no user message and no default_model configured","messagePattern":"QualityRouter: no user message and no default_model configured","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/router_strategy/quality_router/quality_router.py","lineNumber":358,"sourceCode":"\n        for msg in reversed(messages):\n            role = msg.get(\"role\", \"\")\n            content = msg.get(\"content\") or \"\"\n            if isinstance(content, list):\n                text_parts = [\n                    part.get(\"text\", \"\") for part in content if isinstance(part, dict) and part.get(\"type\") == \"text\"\n                ]\n                content = \" \".join(text_parts).strip()\n            if isinstance(content, str) and content:\n                if role == \"user\" and user_message is None:\n                    user_message = content\n                elif role == \"system\" and system_prompt is None:\n                    system_prompt = content\n\n        if user_message is None:\n            verbose_router_logger.debug(\"QualityRouter: No user message found, routing to default model\")\n            if not self.config.default_model:\n                raise ValueError(\"QualityRouter: no user message and no default_model configured\")\n            return PreRoutingHookResponse(\n                model=self.config.default_model,\n                messages=messages,\n                routing_decision=StandardLoggingRoutingDecision(\n                    router_model_name=self.model_name,\n                    router_type=\"quality\",\n                    routed_model=self.config.default_model,\n                    cause=\"default_fallback\",\n                ),\n            )\n\n        # Try keyword override first — it short-circuits complexity classification.\n        keyword_match: Final = self._keyword_override(user_message)\n        if keyword_match is not None:\n            routed_model, matched_keyword = keyword_match\n            verbose_router_logger.info(\n                \"QualityRouter: keyword override matched='%s' routed_model=%s (quality_tier=%s, input_cost_per_token=%s)\",\n                matched_keyword,","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/router_strategy/quality_router/quality_router.py#L340-L376","documentation":"Routing failure in QualityRouter: none of the supplied messages contain user-role text to classify for complexity, and no default_model is configured to fall back on, so a routing decision cannot be made.","triggerScenarios":"Thrown at litellm/router_strategy/quality_router/quality_router.py:358 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include a user message in the request, or configure default_model for the QualityRouter."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}