Skip to content

⚙️ FEATURE: Set task status to RETRY during retry attempts - #90

Merged
FernandoCelmer merged 7 commits into
dotflow-io:feature/84from
aravindhbalaji04:feature/set-retry-status
Mar 31, 2026
Merged

⚙️ FEATURE: Set task status to RETRY during retry attempts#90
FernandoCelmer merged 7 commits into
dotflow-io:feature/84from
aravindhbalaji04:feature/set-retry-status

Conversation

@aravindhbalaji04

@aravindhbalaji04 aravindhbalaji04 commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

PR Title

⚙️ FEATURE: Set task status to RETRY during retry attempts

PR Body

Summary

TypeStatus.RETRY was defined but never used in the retry logic. This PR makes retry attempts visible to workflow observers by setting task.status = TypeStatus.RETRY before each retry sleep, then resetting to IN_PROGRESS after successful retry.

Problem

  • TypeStatus.RETRY existed but was never set during retry attempts
  • Tasks stayed as IN_PROGRESS between retries, making debugging harder
  • After successful retry, status remained incorrectly set to RETRY
  • Callbacks, logs, and notifications couldn't distinguish first execution from retries

Changes

  • Store task as instance attribute (self._current_task) instead of fragile kwargs.pop
  • Set task.status = TypeStatus.RETRY before sleep(retry_delay) in retry loop
  • Reset task.status = TypeStatus.IN_PROGRESS after successful retry (if attempt > 1)
  • Add test verifying RETRY status is set during retry attempt and reset after success

Impact

  • Callbacks, logs, and notifications now reflect accurate retry state
  • Status correctly represents task lifecycle: IN_PROGRESSRETRYIN_PROGRESS → (eventual COMPLETED/FAILED)
  • No breaking changes — only adds visibility to existing retry behavior
  • TypeStatus.RETRY is now functional instead of dead code

Test Plan

  • poetry run pytest tests/core/test_action.py -q (11 passed)
  • poetry run tox -e dotflow-py310 (OK)
  • ✅ New test: test_sets_retry_status_before_retrying validates timing and reset behavior

Related

Fixes the issue where retry attempts were invisible to workflow monitoring systems and status remained incorrect after retry completion.

Copilot AI review requested due to automatic review settings March 26, 2026 08:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Issue #84 by making retry attempts observable: when an action fails and is about to retry, the associated Task is now transitioned to TypeStatus.RETRY so logs/notifications can reflect the retry state.

Changes:

  • Pass the task object internally into Action._run_action() (without forwarding it to user functions).
  • Set task.status = TypeStatus.RETRY immediately before the retry delay/sleep.
  • Add a unit test intended to verify RETRY is set between retry attempts.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
dotflow/core/action.py Threads the task into _run_action() and sets TypeStatus.RETRY on retry paths.
tests/core/test_action.py Adds a test for retry status visibility.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dotflow/core/action.py
Comment thread tests/core/test_action.py
Comment on lines +70 to +83
def test_sets_retry_status_before_retrying(self):
calls = {"count": 0}

def flaky_step():
calls["count"] += 1
if calls["count"] == 1:
raise Exception("Fail once")
return "ok"

inside = Action(flaky_step, retry=2, retry_delay=0)
inside(task=self.task)

self.assertEqual(self.task.status, TypeStatus.RETRY)

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test asserts the task’s final status is RETRY after the action completes successfully. In actual workflow execution (Execution), the task status is set to COMPLETED on success, so RETRY is only meant to be observable between attempts. Consider asserting RETRY at the correct moment (e.g., check self.task.status on the second call inside flaky_step, or patch dotflow.core.action.sleep to assert the status when the retry delay is entered), and also assert the action ultimately returns successfully / status transitions to the expected terminal status in the real execution path.

Copilot uses AI. Check for mistakes.
@FernandoCelmer
FernandoCelmer changed the base branch from master to develop March 26, 2026 15:56
@FernandoCelmer
FernandoCelmer self-requested a review March 26, 2026 17:35
@FernandoCelmer FernandoCelmer added the enhancement New feature or request label Mar 26, 2026

@FernandoCelmer FernandoCelmer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Code Review

Code issues found: 3

# Severity Description
1 [Blocking] Task status remains RETRY after successful retry
2 [Suggestion] Fragile kwargs.pop approach for passing task
3 [Suggestion] Test does not verify mid-retry status

Comment thread dotflow/core/action.py
Comment thread dotflow/core/action.py
Comment thread tests/core/test_action.py
actions-user and others added 5 commits March 27, 2026 02:28
TypeStatus.RETRY was defined but never used. Tasks now correctly
transition to RETRY status before each retry attempt, then reset to
IN_PROGRESS after successful retry, making retry behavior visible to
callbacks, logs, and notifications.

- Store task as instance attribute (_current_task) instead of kwargs.pop
- Set task.status = TypeStatus.RETRY before sleep in retry loop
- Reset task.status = TypeStatus.IN_PROGRESS after successful retry
- Add test verifying RETRY status timing and IN_PROGRESS reset

Fixes issue where retry attempts were invisible to workflow observers
and status remained incorrectly set to RETRY after completion.

Made-with: Cursor
@aravindhbalaji04
aravindhbalaji04 force-pushed the feature/set-retry-status branch from 44040d2 to 08a1571 Compare March 27, 2026 04:55
@aravindhbalaji04

Copy link
Copy Markdown
Contributor Author

@FernandoCelmer i have pushed my latest with the fixes which you have mentioned, please check that out

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dotflow/core/action.py
Comment thread pyproject.toml
Comment thread .code_quality/ruff.toml Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread dotflow/__init__.py
Comment thread LAST_VERSION
Comment thread dotflow/core/action.py
@FernandoCelmer
FernandoCelmer changed the base branch from develop to feature/84 March 31, 2026 01:20
@FernandoCelmer
FernandoCelmer merged commit 07658ef into dotflow-io:feature/84 Mar 31, 2026
8 of 14 checks passed
@FernandoCelmer FernandoCelmer mentioned this pull request Mar 31, 2026
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants