{"record":{"id":"061790c9fe181052","repo":"deepset-ai/haystack","slug":"all-len-self-chat-generators-chat-generators-fa","errorCode":null,"errorMessage":"All {len(self.chat_generators)} chat generators failed. Last error: {last_error}. Failed chat generators: [{failed_names}]","messagePattern":"All (.+?) chat generators failed\\. Last error: (.+?)\\. Failed chat generators: \\[(.+?)\\]","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"haystack/components/generators/chat/fallback.py","lineNumber":206,"sourceCode":"                        \"successful_chat_generator_class\": gen_name,\n                        \"total_attempts\": idx + 1,\n                        \"failed_chat_generators\": failed,\n                    }\n                )\n                return {\"replies\": replies, \"meta\": meta}\n            except Exception as e:  # noqa: BLE001 - fallback logic should handle any exception\n                logger.warning(\n                    \"ChatGenerator {chat_generator} failed with error: {error}\", chat_generator=gen_name, error=e\n                )\n                failed.append(gen_name)\n                last_error = e\n\n        failed_names = \", \".join(failed)\n        msg = (\n            f\"All {len(self.chat_generators)} chat generators failed. \"\n            f\"Last error: {last_error}. Failed chat generators: [{failed_names}]\"\n        )\n        raise RuntimeError(msg)\n\n    @component.output_types(replies=list[ChatMessage], meta=dict[str, Any])\n    async def run_async(\n        self,\n        messages: list[ChatMessage] | str,\n        generation_kwargs: dict[str, Any] | None = None,\n        tools: ToolsType | None = None,\n        streaming_callback: StreamingCallbackT | None = None,\n    ) -> dict[str, list[ChatMessage] | dict[str, Any]]:\n        \"\"\"\n        Asynchronously execute chat generators sequentially until one succeeds.\n\n        :param messages: The conversation history as a list of ChatMessage instances.\n        :param generation_kwargs: Optional parameters for the chat generator (e.g., temperature, max_tokens).\n        :param tools: A list of Tool and/or Toolset objects, or a single Toolset for function calling capabilities.\n        :param streaming_callback: Optional callable for handling streaming responses.\n        :returns: A dictionary with:\n            - \"replies\": Generated ChatMessage instances from the first successful generator.","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/generators/chat/fallback.py#L188-L224","documentation":"FallbackChatGenerator.run() tries each configured chat generator in order and collects failures. When every generator raised, it raises RuntimeError summarizing how many failed, the last underlying error, and the names of the failed generators. The root causes are the innermost errors of the wrapped generators.","triggerScenarios":"Calling `run(messages=...)` when all wrapped generators raise (e.g. invalid API keys, exhausted quotas, network failures, misconfigured models) — including the case of a single generator that fails, since 'all' then means that one.","commonSituations":"Expired or wrong API keys for every provider in the list; rate limits hitting all generators simultaneously; all configured deployments deleted/renamed on the provider side; single-generator fallbacks used as a plain wrapper whose backend is down.","solutions":["Read the 'Last error:' section of the message — it contains the underlying exception to fix first","Check API keys, quotas, and model/deployment names for every wrapped generator","Verify network/proxy access to each provider endpoint","Add more diverse fallback generators (different providers) so a single outage doesn't exhaust the list"],"exampleFix":"// before\ntry:\n    res = fallback.run(messages=msgs)\nexcept RuntimeError as e:\n    print(e)  # inspect 'Last error' and failed generator names\n// after\ngenerator = FallbackChatGenerator([AzureChatGenerator(model=\"gpt-4o\"), OpenAIChatGenerator(model=\"gpt-4o-mini\")])\n# ensure at least one generator has valid, independently billed credentials","handlingStrategy":"fallback","validationCode":"# preflight: check each generator's client config before pipeline use\nfor g in fallback.chat_generators:\n    d = g.to_dict()\n    assert d.get(\"init_parameters\", {}).get(\"api_base_url\") or d.get(\"init_parameters\", {}).get(\"azure_endpoint\")","typeGuard":null,"tryCatchPattern":"try:\n    result = fallback.run(messages=msgs)\nexcept RuntimeError as e:\n    # message lists count, last error, and failed generator names\n    logger.error(\"all fallback generators failed: %s\", e)\n    raise","preventionTips":["Diversify fallback generators across providers/credentials","Rotate and validate API keys; monitor quotas","Parse the 'Last error:' portion to reach the root cause quickly"],"tags":["fallback","runtime-error","api-failure","all-generators-failed"],"backgroundTag":"all-fallbacks-exhausted","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}