{"record":{"id":"9e02c200420109e4","repo":"deepset-ai/haystack","slug":"no-route-fired-routes-self-routes","errorCode":null,"errorMessage":"No route fired. Routes: {self.routes}","messagePattern":"No route fired\\. Routes: (.+?)","errorType":"exception","errorClass":"NoRouteSelectedException","httpStatus":null,"severity":"error","filePath":"haystack/components/routers/conditional_router.py","lineNumber":480,"sourceCode":"                            if not self._unsafe:\n                                output_value = ast.literal_eval(output_value)\n\n                    # Validate output type if needed\n                    if self._validate_output_type and not self._output_matches_type(output_value, output_type):\n                        raise ValueError(f\"Route '{output_name}' type doesn't match expected type\")  # noqa: TRY301\n\n                    result[output_name] = output_value\n\n                return result\n\n            except Exception as e:\n                # If this was a type-validation failure or missing passthrough variable, let it propagate\n                if isinstance(e, ValueError):\n                    raise\n                msg = f\"Error evaluating condition for route '{route}': {e}\"\n                raise RouteConditionException(msg) from e\n\n        raise NoRouteSelectedException(f\"No route fired. Routes: {self.routes}\")\n\n    def _validate_routes(self, routes: list[Route]) -> None:\n        \"\"\"\n        Validates a list of routes.\n\n        :param routes: A list of routes.\n        \"\"\"\n        for route in routes:\n            try:\n                keys = set(route.keys())\n            except AttributeError as e:\n                raise ValueError(f\"Route must be a dictionary, got: {route}\") from e\n\n            mandatory_fields = {\"condition\", \"output\", \"output_type\", \"output_name\"}\n            has_all_mandatory_fields = mandatory_fields.issubset(keys)\n            if not has_all_mandatory_fields:\n                raise ValueError(\n                    f\"Route must contain 'condition', 'output', 'output_type' and 'output_name' fields: {route}\"","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/routers/conditional_router.py#L462-L498","documentation":"run() evaluated every route's condition and none rendered truthy, so no output could be selected. Haystack raises NoRouteSelectedException listing all configured routes to help debug why each condition was False.","triggerScenarios":"ConditionalRouter.run() where every route's condition renders to False (or fails ast.literal_eval into a falsy value in safe mode) for the given inputs.","commonSituations":"Conditions that don't cover all input cases (no catch-all else route); variables rendered as strings (\"True\"/\"False\" handled, but comparisons like \"1 == 2\" fine while free text literal_eval fails to False-ish values); upstream component producing unexpected values.","solutions":["Add a final catch-all route with condition \"True\" as a default.","Print/log the inputs passed to run() and test each condition template against them.","Ensure conditions render to a Python-literal boolean in safe mode (e.g. \"{{ query|length > 10 }}\").","Catch NoRouteSelectedException and implement fallback logic at the call site."],"exampleFix":"// before\nroutes=[Route(condition=\"q == 'a'\", output=\"a\", output_type=str, output_name=\"out\")]\n// after\nroutes=[Route(condition=\"q == 'a'\", output=\"a\", output_type=str, output_name=\"out\"),\n        Route(condition=\"True\", output=\"default\", output_type=str, output_name=\"default\")]","handlingStrategy":"try-catch","validationCode":"fired = any(eval_literal(env.from_string(r[\"condition\"]).render(**kwargs))\n            for r in router.routes)\nassert fired, \"no route condition is True for given inputs\"","typeGuard":"def some_route_fires(router, kwargs: dict) -> bool:\n    import ast\n    for r in router.routes:\n        try:\n            if ast.literal_eval(router._env.from_string(r[\"condition\"]).render(**kwargs)):\n                return True\n        except Exception:\n            continue\n    return False","tryCatchPattern":"try:\n    result = router.run(**kwargs)\nexcept NoRouteSelectedException:\n    result = {\"default\": fallback_value}","preventionTips":["Always include a catch-all route with condition \"True\" as the last entry.","Log router inputs when debugging which conditions evaluate false.","Cover all upstream output variants in your route conditions."],"tags":["router","no-route","jinja"],"backgroundTag":"no-route-selected","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}