Repository navigation
fix(workflows): save run state before logging in workflow run - #5583
Open
chuenchen309 wants to merge 1 commit into
Open
chuenchen309 wants to merge 1 commit into
chuenchen309 wants to merge 1 commit into
Conversation
execute() appended the workflow_interrupted, workflow_failed and workflow_finished events before saving the matching state. When log.jsonl cannot be written, the run stays persisted as running and workflow resume refuses it. github#5492 fixed the same ordering in resume(). Assisted-by: Claude Code (model: Claude Opus 5.5, autonomous)
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The reordered PAUSED transition lacks an execute() log-failure regression test verifying that PAUSED persists and execution resumes after logging is repaired, leaving the interrupted-run bug unguarded.
1 open issue
What changed in this PR
Extends the state-persistence fix from #5492 to workflow run, preventing lifecycle log failures from leaving paused, failed, or completed runs persisted as running.
Changes:
- Saves run state before interruption, failure, and completion log events.
- Adds regressions for failed-state persistence and completion-state preservation when logging fails.
Review analysis is AI-generated by GitHub Copilot (model: unknown; automated mode) for the requesting reviewer. Tests were not run during this review.
| File | Description |
|---|---|
tests/workflows/test_composition_execution.py |
Adds two execute-path log-failure regression tests. |
src/specify_cli/workflows/engine.py |
Persists execute-path state transitions before lifecycle logging. |
Review effort: Balanced (adaptive)
Comment on lines
1226
to
+1227
| state.save() | ||
| state.append_log({"event": "workflow_interrupted"}) |
This branch has not been deployed
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
#5492 fixed #5489 for
workflow resumeby saving the paused/failed/completed state before appending the lifecycle log event.WorkflowEngine.execute()still does it the other way round in the same three places, soworkflow runcan leave a run stuck asrunningthe same way: iflog.jsonlcan't be written, the failure handler'sworkflow_failedappend raises before thefailedstate is saved, and a failedworkflow_finishedappend leaves a run whose steps all completed persisted asrunning. Either way a laterworkflow resumeis refused withCannot resume run '<id>' with status 'running'.This applies the same ordering to
execute(): save first, then log.Testing
Set up this checkout's
.venvand editable install using the local development guide. Run commands from the checkout root..venv/bin/specify --help(Windows PowerShell:.\.venv\Scripts\specify.exe --help).venv/bin/python -m pytest tests -q(Windows PowerShell:.\.venv\Scripts\python.exe -m pytest tests -q); use affected test paths for focused checks andLC_ALL=en_US.UTF-8on macOSAdded two regressions next to the #5492 resume tests (a log that can't be written during
execute(), and a failedworkflow_finishedappend); both fail onmainwith the persisted status stillrunningand pass with this change.tests/workflowspasses (990 tests), as do the other 37 test files that driveWorkflowEngineor the workflow CLI commands (4403 passed, 62 skipped).ruff checkis clean on the changed files.AI Disclosure
AI disclosure: This PR was written by an AI coding agent, Claude Code (model: Claude Opus 5.5), working autonomously on behalf of the account holder, with no human review before submission. The agent compared
execute()with the resume path fixed in #5492, wrote the fix and the tests, ran the tests above, and wrote this description. The commit carries anAssisted-by:trailer.