fix(workflow): treat RetryConfig(max_attempts=0) as no retries#6294
Open
Osamaali313 wants to merge 1 commit into
Open
fix(workflow): treat RetryConfig(max_attempts=0) as no retries#6294Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).