fix(workflow): treat RetryConfig(max_attempts=0) as no retries#6294
fix(workflow): treat RetryConfig(max_attempts=0) as no retries#6294Osamaali313 wants to merge 4 commits into
Conversation
RetryConfig.max_attempts documents "If 0 or 1, it means no retries. If not specified, default to 5." and defaults to None. _should_retry_node resolved the default with `retry_config.max_attempts or 5`, which treats an explicit 0 as falsy and replaces it with 5, so a node configured for no retries ran up to 5 attempts. Use an explicit None check so 0 and 1 disable retries while the unset (None) case still defaults to 5.
Wrap the long _should_retry_node assertions to satisfy the repo's pyink (line-length 80) pre-commit hook. No behavior change.
|
Pushed a small formatting commit — Heads up on the other red check: the Mypy failure isn't from this PR's diff — the "new" errors it lists are all in |
|
Hi @Osamaali313 , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share. |
|
Hi @wyf7107 , can you please review this. LGTM. |
Fixes #6293
Problem
RetryConfig.max_attemptsis documented as "Maximum number of attempts, including the original request. If 0 or 1, it means no retries. If not specified, default to 5." and defaults toNone. But_should_retry_noderesolved the default with a falsy-coalescingor:0is falsy, soRetryConfig(max_attempts=0)— documented as "no retries" — is silently replaced with5, running 4 retries instead of none.max_attempts=1happens to work (1 or 5 == 1); only the documented0case is broken. The intended "unset" sentinel isNone, which must still map to5.WorkflowandRetryConfigare public API (both in__all__, no@experimentalgate), and this drives every workflow node's retry loop via_NodeRunner._attempt_retry.Fix
Tests
Added
TestShouldRetryNodetotests/unittests/workflow/utils/test_retry_utils.py(the file previously covered only_get_retry_delay), asserting:max_attemptsof0and1disable retriesmax_attempts=3retries until the limitNone) defaults to 5Before the fix, the
max_attempts=0case fails; after, it passes. The fulltests/unittests/workflow/suite passes (619 passed, no regressions).