Workflows batch runs: settlement reads the current workflow, so editing a failed email step reports the run as completed
Problem
A batch run whose email step failed can be reported as completed if the workflow is edited before the run settles.
Settlement decides which failures count as send failures with send_step_ids, which reads the workflow's current actions:
https://github.com/PostHog/posthog/blob/76019976d8c/products/workflows/backend/services/batch_run_outcome.py#L85-L89
When a failed email step is removed or replaced (a new action id) between the run and the settlement check, its failed metrics no longer match any id in send_step_ids. The run counts zero errored sends and settles as completed.
Steps
- Run a batch workflow whose email step fails for every recipient.
- Before settlement runs, edit the workflow so that email step is removed or replaced.
- The batch run settles as
completed, and settlement doesn't check it again.
Expected
Settlement classifies failures by the send steps of the workflow version that produced the run's metrics, so editing the workflow afterwards doesn't change the outcome.
Notes
- Options: store the send step ids, or the workflow version, on the batch run when it starts, and read them at settlement.
- A test that edits the workflow before settlement would cover it.
- Found in a code review of a stacked PR that merged master forward.
Hi @Silthus, I'd like to work on this. I'd make batch-run settlement use the step IDs recorded at run time instead of the workflow's current actions, with a test that edits a failed email step before settlement. Okay if I pick it up?