Repository navigation
Conversation
Executor.handle_failure cached its outcome by history event id only. Idempotent tasks with the same arguments get the same id, so two submissions of one activity in an execution share its events. Since propagated attributes stay on the task (#486), those submissions can differ: one inside Group(raises_on_failure=False), one standalone and mandatory. Failure scenario: the optional submission handles the terminal failure first. default_failure_handling returns the failed future, which is cached. The mandatory submission then hits the cache, gets the same future, and never raises: the workflow completes although a mandatory activity failed. In the other order the mandatory one raises before anything is cached, so the workflow fails as it should. The cache key is now (event id, payload). The payload is the task's activity, or workflow class: shared by tasks with the same attributes, their own TaskActivity or subclass once a canvas propagated attributes to them. Neither defines __eq__ or __hash__, so they key by identity, and the dict keeps them alive for the replay. Tasks that share the payload still call on_task_failure once per failure; tasks with their own attributes now each call it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
simpleflow/swf/executor.py,handle_failure: thehandled_failurescache is keyed by(event id, swf_task.payload)instead of the event id alone. The payload is the task's activity, or its workflow class for a child workflow.Why
Idempotent tasks with the same arguments get the same id, so two submissions of one activity in an execution share its history events. Since #486, propagated attributes stay on the task, so those two submissions can have different failure semantics.
Failure scenario: an idempotent activity is submitted once inside
Group(..., raises_on_failure=False)and once standalone, where it is mandatory, and it fails for good.default_failure_handlingreturns the failed future and it is cached by event id. The mandatory submission hits the cache and gets that future instead of raising, so the workflow completes although a mandatory activity failed.Botify runs into this: two analysis features build the same idempotent base-reference activity, one of them inside an optional group.
Choices
raises_on_failure.on_task_failurecan read any of the task's attributes, so the key is the object that holds them.on_task_failureis still called once per failure for them.TaskActivity, or workflow subclass, and so its own entry.Activitynor a workflow class defines__eq__or__hash__. The dict holds the payloads, so an id cannot be reused during the replay.on_task_failure. They used to share one call.Tests
tests/test_simpleflow/swf/test_executor.py,TestFailureOfASharedTask, replays of one idempotent activity that fails in the first decision and is used twice:on_task_failureis called once;on_task_failureis called once per task, with the same task id.Results:
uv run --frozen --all-extras --group=dev pytest): 516 passed, 10 skipped, 3 xfailed.uvx prek run --all-filesis clean.Not addressed
🤖 Generated with Claude Code