{"record":{"id":"4a457670ecb7e7ec","repo":"run-llama/llama_index","slug":"at-least-one-error-to-retry-needs-to-be-provided","errorCode":null,"errorMessage":"At least one error to retry needs to be provided","messagePattern":"At least one error to retry needs to be provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/utils.py","lineNumber":261,"sourceCode":"    min_backoff_secs: float = 0.5,\n    max_backoff_secs: float = 60.0,\n) -> Any:\n    \"\"\"\n    Execute lambda function with retries and exponential backoff.\n\n    Args:\n        lambda_fn (Callable): Function to be called and output we want.\n        errors_to_retry (List[ErrorToRetry]): List of errors to retry.\n            At least one needs to be provided.\n        max_tries (int): Maximum number of tries, including the first. Defaults to 10.\n        min_backoff_secs (float): Minimum amount of backoff time between attempts.\n            Defaults to 0.5.\n        max_backoff_secs (float): Maximum amount of backoff time between attempts.\n            Defaults to 60.\n\n    \"\"\"\n    if not errors_to_retry:\n        raise ValueError(\"At least one error to retry needs to be provided\")\n\n    error_checks = {\n        error_to_retry.exception_cls: error_to_retry.check_fn\n        for error_to_retry in errors_to_retry\n    }\n    exception_class_tuples = tuple(error_checks.keys())\n\n    backoff_secs = min_backoff_secs\n    tries = 0\n\n    while True:\n        try:\n            return lambda_fn()\n        except exception_class_tuples as e:\n            traceback.print_exc()\n            tries += 1\n            if tries >= max_tries:\n                raise","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/utils.py#L243-L279","documentation":"The retry_decorator-style helper in llama_index.core.utils (used to retry LLM calls on transient errors) requires a non-empty errors_to_retry list; with nothing to match it cannot decide what to retry, so it raises ValueError immediately. ErrorToRetry entries pair an exception class with an optional check_fn that inspects the exception instance.","triggerScenarios":"Calling the decorated function (or constructing via the helper) with errors_to_retry=[] or errors_to_retry=None - typically when the list is built dynamically from config and ends up empty, or a default argument was overridden.","commonSituations":"Config-driven retry setups where the error classes list comes from YAML and is missing/empty; refactors that moved the defaults but left the parameter mandatory; passing tuples/strings instead of ErrorToRetry instances.","solutions":["Provide at least one entry: errors_to_retry=[ErrorToRetry(exception_cls=RateLimitError)].","If config may legitimately have none, skip applying the decorator when the list is empty.","For OpenAI-style APIs, the common retry set is RateLimitError, APIConnectionError, APITimeoutError."],"exampleFix":"# before\n fn = retry_decorator(\n     lambda_fn=call_llm,\n     errors_to_retry=[],  # -> ValueError\n )(call_llm)\n\n# after\nfrom openai import APIConnectionError, RateLimitError\nfrom llama_index.core.utils import ErrorToRetry\n\n fn = retry_decorator(\n     lambda_fn=call_llm,\n     errors_to_retry=[\n         ErrorToRetry(exception_cls=RateLimitError),\n         ErrorToRetry(exception_cls=APIConnectionError),\n     ],\n )(call_llm)","handlingStrategy":"validation","validationCode":"DEFAULT_RETRY_ERRORS = (\n    ErrorToRetry(exception_cls=RateLimitError),\n    ErrorToRetry(exception_cls=APIConnectionError),\n)\n\ndef retry_errors_or_default(errors):\n    return errors or list(DEFAULT_RETRY_ERRORS)","typeGuard":"def is_valid_errors_to_retry(errors) -> bool:\n    return bool(errors) and all(\n        hasattr(e, 'exception_cls') and isinstance(e.exception_cls, type)\n        and issubclass(e.exception_cls, BaseException)\n        for e in errors\n    )","tryCatchPattern":"try:\n    fn = retry_decorator(lambda_fn=call, errors_to_retry=errors)(call)\nexcept ValueError as e:\n    if 'error to retry' in str(e):\n        fn = retry_decorator(lambda_fn=call, errors_to_retry=list(DEFAULT_RETRY_ERRORS))(call)\n    else:\n        raise","preventionTips":["Provide a non-empty default list of ErrorToRetry whenever retry config is dynamic.","Skip applying the decorator entirely when the configured list is empty rather than passing [].","Validate that entries are ErrorToRetry instances with exception classes, not strings."],"tags":["retry","llm","configuration","value-error"],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}