From 466f766f046217065601a7b653f7c52641dbb741 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:55:00 +0000 Subject: [PATCH] Clarify sync retry state transitions Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> Agent-Logs-Url: https://github.com/we-promise/sure/sessions/ea7a06f4-8344-4a00-877a-eda8cdfdc16a --- app/models/sync.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/sync.rb b/app/models/sync.rb index 0fbf00e3d..0cb529577 100644 --- a/app/models/sync.rb +++ b/app/models/sync.rb @@ -105,7 +105,7 @@ class Sync < ApplicationRecord def fail_for_retry_exhaustion!(error_message) Sync.transaction do lock! - start! if may_start? + start! if pending? fail! if may_fail? update!(error: error_message) end @@ -163,6 +163,9 @@ class Sync < ApplicationRecord private def reset_for_retry! + # We intentionally bypass callbacks/state events here so the same sync record + # can become retryable again without firing post-sync hooks or extra + # transition side effects while the job is being retried. update_columns( status: "pending", error: nil,