From 3be23c9f18610f8130abb46ae0d0b8439f1f93e5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 13:56:06 +0000 Subject: [PATCH] Polish sync retry handling comments and assertions 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 | 4 +++- test/models/sync_test.rb | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/sync.rb b/app/models/sync.rb index 0cb529577..ba19bac01 100644 --- a/app/models/sync.rb +++ b/app/models/sync.rb @@ -105,6 +105,8 @@ class Sync < ApplicationRecord def fail_for_retry_exhaustion!(error_message) Sync.transaction do lock! + # Retry exhaustion can leave the sync in `pending` because we reset it + # after each rate-limit error to make the next ActiveJob retry retryable. start! if pending? fail! if may_fail? update!(error: error_message) @@ -118,9 +120,9 @@ class Sync < ApplicationRecord Sync.transaction do lock! + return if pending? # If this is the "parent" and there are still children running, don't finalize. return unless all_children_finalized? - return if pending? if syncing? if has_failed_children? diff --git a/test/models/sync_test.rb b/test/models/sync_test.rb index 3393940da..ecb78f816 100644 --- a/test/models/sync_test.rb +++ b/test/models/sync_test.rb @@ -59,6 +59,7 @@ class SyncTest < ActiveSupport::TestCase sync.reload assert_equal "pending", sync.status assert_nil sync.error + assert_not_nil sync.pending_at assert_nil sync.syncing_at assert_nil sync.failed_at assert_nil sync.completed_at