Skip to content

fix: ensure retry=0 executes the task exactly once - #159

Merged
FernandoCelmer merged 4 commits into
dotflow-io:feature/143from
avarga1:fix/bug-143-retry-zero
Apr 8, 2026
Merged

fix: ensure retry=0 executes the task exactly once#159
FernandoCelmer merged 4 commits into
dotflow-io:feature/143from
avarga1:fix/bug-143-retry-zero

Conversation

@avarga1

@avarga1 avarga1 commented Apr 7, 2026

Copy link
Copy Markdown

Description

  • dotflow/core/action.py: Use max(1, self.retry) to ensure retry=0 executes the task at least once
  • tests/core/test_action.py: Add test verifying retry=0 runs the task exactly once

Motivation and Context

With retry=0, range(1, 0+1) produces an empty range, so the task never executes and returns None silently. The fix guarantees at least one execution attempt.

Closes #143

Types of changes

  • Bug fix (change that fixes an issue)
  • New feature (change which adds functionality)
  • Documentation

Checklist

  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the CHANGELOG
  • I have updated the documentation accordingly

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.
Comment thread dotflow/core/action.py Outdated
@FernandoCelmer FernandoCelmer added bug Something isn't working edge-case Edge case handling labels Apr 7, 2026
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.
@avarga1

avarga1 commented Apr 7, 2026

Copy link
Copy Markdown
Author

Good catch — you're right, the raise guard was still comparing against self.retry (always False when retry=0 since attempt starts at 1). Fixed by extracting max_attempts = max(1, self.retry) and using it in both the loop bound and the raise guard. Also added test_retry_zero_raises_on_failure as suggested.

@FernandoCelmer
FernandoCelmer changed the base branch from develop to feature/143 April 8, 2026 07:27
@FernandoCelmer
FernandoCelmer merged commit 1b4be4f into dotflow-io:feature/143 Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working edge-case Edge case handling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants