fix: ensure retry=0 executes the task exactly once - #159
Merged
FernandoCelmer merged 4 commits intoApr 8, 2026
Conversation
Fixes dotflow-io#143 — the retry loop used range(1, self.retry + 1), so passing retry=0 produced an empty range and the task never ran at all. Wrap with max(1, self.retry) so the loop always executes at least one attempt regardless of the retry value.
The raise guard previously compared attempt == self.retry, which is always False when retry=0 (attempt is 1 after max(1, 0)). This caused failing tasks with retry=0 to silently return None instead of raising. Extract the clamped bound into max_attempts and use it in both the range() and the raise guard. Also adds test_retry_zero_raises_on_failure per review feedback.
Author
|
Good catch — you're right, the raise guard was still comparing against |
7 tasks
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.
Description
max(1, self.retry)to ensureretry=0executes the task at least onceretry=0runs the task exactly onceMotivation and Context
With
retry=0,range(1, 0+1)produces an empty range, so the task never executes and returnsNonesilently. The fix guarantees at least one execution attempt.Closes #143
Types of changes
Checklist