streamlit/streamlit · error · ValueError
max_attempts must be at least 1, got {max_attempts!r}.
Error message
max_attempts must be at least 1, got {max_attempts!r}. What it means
Error "max_attempts must be at least 1, got {max_attempts!r}." thrown in streamlit/streamlit.
Source
Thrown at lib/streamlit/connections/retry_util.py:80
An optional callback invoked after every failed, retryable attempt,
including the final one before the exception is re-raised. The
connections use this to reset the connection between attempts.
sleep
The function used to sleep between attempts. Injectable for testing;
defaults to :func:`time.sleep`.
Returns
-------
Callable
A decorator that wraps a function with the configured retry behavior.
Raises
------
ValueError
If ``max_attempts`` is less than ``1`` or ``wait_seconds`` is negative.
"""
if max_attempts < 1:
raise ValueError(f"max_attempts must be at least 1, got {max_attempts!r}.")
if wait_seconds < 0:
raise ValueError(f"wait_seconds must be non-negative, got {wait_seconds!r}.")
def decorator(func: Callable[_P, _R]) -> Callable[_P, _R]:
@functools.wraps(func)
def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
attempt = 1
while True:
try:
return func(*args, **kwargs)
except Exception as exc: # noqa: PERF203 — retry loop must catch per-iteration
# The predicate rejected this exception: re-raise it
# immediately with no wait or `after` callback.
if not retry_on_exception(exc):
raise
if after is not None:
after()View on GitHub (pinned to 202661fc55)
When it happens
Trigger: Thrown at lib/streamlit/connections/retry_util.py:80 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of streamlit/streamlit@202661fc55 (2026-08-26).
Data as JSON: /api/errors/7b5cdc674840585e.
Report an issue: GitHub.