{"record":{"id":"7b5cdc674840585e","repo":"streamlit/streamlit","slug":"max-attempts-must-be-at-least-1-got-max-attempts","errorCode":null,"errorMessage":"max_attempts must be at least 1, got {max_attempts!r}.","messagePattern":"max_attempts must be at least 1, got (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/streamlit/connections/retry_util.py","lineNumber":80,"sourceCode":"        An optional callback invoked after every failed, retryable attempt,\n        including the final one before the exception is re-raised. The\n        connections use this to reset the connection between attempts.\n    sleep\n        The function used to sleep between attempts. Injectable for testing;\n        defaults to :func:`time.sleep`.\n\n    Returns\n    -------\n    Callable\n        A decorator that wraps a function with the configured retry behavior.\n\n    Raises\n    ------\n    ValueError\n        If ``max_attempts`` is less than ``1`` or ``wait_seconds`` is negative.\n    \"\"\"\n    if max_attempts < 1:\n        raise ValueError(f\"max_attempts must be at least 1, got {max_attempts!r}.\")\n    if wait_seconds < 0:\n        raise ValueError(f\"wait_seconds must be non-negative, got {wait_seconds!r}.\")\n\n    def decorator(func: Callable[_P, _R]) -> Callable[_P, _R]:\n        @functools.wraps(func)\n        def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:\n            attempt = 1\n            while True:\n                try:\n                    return func(*args, **kwargs)\n                except Exception as exc:  # noqa: PERF203 — retry loop must catch per-iteration\n                    # The predicate rejected this exception: re-raise it\n                    # immediately with no wait or `after` callback.\n                    if not retry_on_exception(exc):\n                        raise\n\n                    if after is not None:\n                        after()","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/streamlit/streamlit/blob/202661fc552db98c2ba0bb0e113d619689baf9de/lib/streamlit/connections/retry_util.py#L62-L98","documentation":"Error \"max_attempts must be at least 1, got {max_attempts!r}.\" thrown in streamlit/streamlit.","triggerScenarios":"Thrown at lib/streamlit/connections/retry_util.py:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"202661fc552db98c2ba0bb0e113d619689baf9de","analyzedAt":"2026-08-26T09:13:21.291Z","schemaVersion":2},"datasetVersion":"2026-08-26T14:46:13.012Z"}