Skip to content

Conversation

@mj-palanker
Copy link
Contributor

@mj-palanker mj-palanker commented Sep 12, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Improved sync resilience: when a targeted resource is missing during a partial sync, the system logs a warning, skips that resource, and continues processing remaining actions—reducing aborted syncs and improving overall reliability.

@mj-palanker mj-palanker requested a review from ggreer September 12, 2025 19:43
@coderabbitai
Copy link

coderabbitai bot commented Sep 12, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adjusts the main sync loop: when a Partial SyncTargetedResource operation returns a NotFound error and no retry is advised, the loop logs a targeted-resource not-found warning, finishes the state action, and continues to remaining actions instead of returning an error.

Changes

Cohort / File(s) Summary
Sync loop partial-target handling
pkg/sync/syncer.go
Add NotFound-specific handling for Partial SyncTargetedResource ops: if error is NotFound and not retriable, log a targeted-resource not-found warning, finish the current state action, and continue processing remaining actions instead of propagating the error.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Syncer as Syncer Loop
  participant Action as SyncTargetedResource Op
  participant Retry as ShouldWaitAndRetry
  participant Logger as Logger

  Syncer->>Action: Execute Partial targeted-resource action
  Action-->>Syncer: Error (NotFound)
  Syncer->>Retry: ShouldWaitAndRetry(err)?
  alt Retry advised
    Retry-->>Syncer: true
    Syncer->>Syncer: Wait and retry action
  else No retry advised
    Retry-->>Syncer: false
    Syncer->>Logger: Log targeted-resource not-found warning
    Syncer->>Syncer: Finish state action and continue loop
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title succinctly and accurately describes the primary change: targeted-sync errors are logged and no longer stop the entire sync, which matches the NotFound-handling for Partial targeted resource operations in the diff. It is concise, on-topic, and clear for a reviewer scanning history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Poem

Thump—one resource hopped away,
I sniff, I log, then skip the fray.
No halt, no wail, just steady stride,
Carrots kept for the next ride.
Tiny paws, the loop goes on—🥕🐇

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89f8bd9 and b5e54c9.

📒 Files selected for processing (1)
  • pkg/sync/syncer.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/sync/syncer.go (1)
pkg/connectorstore/connectorstore.go (1)
  • SyncTypePartial (15-15)
🪛 GitHub Check: go-lint
pkg/sync/syncer.go

[failure] 495-495:
unnecessary conversion (unconvert)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Cursor Bugbot
  • GitHub Check: go-test (1.25.x, windows-latest)
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mjp/ignore-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mj-palanker mj-palanker changed the title swallow errors from targeted sync Log Errors from Targeted Sync, but don't stop the whole sync Sep 12, 2025
cursor[bot]

This comment was marked as outdated.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ffd464 and 89f8bd9.

📒 Files selected for processing (1)
  • pkg/sync/syncer.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: go-test (1.25.x, windows-latest)

Comment on lines 496 to 499
l.Error("max attempts reached for sync targeted resource action", zap.Any("stateAction", stateAction), zap.Error(err))
// We want to continue here to make sure we finish other syncs
// we need a better solution for this.
continue
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Finish the action (and record a warning) to avoid an infinite loop when swallowing the error.

You continue without s.state.FinishAction(ctx), so the same SyncTargetedResourceOp stays at the top of the stack and will be retried forever (since ShouldWaitAndRetry already returned false). Finish the action and optionally add the error to warnings so the global cap can trip if needed.

-            if !retryer.ShouldWaitAndRetry(ctx, err) {
-                l.Error("max attempts reached for sync targeted resource action", zap.Any("stateAction", stateAction), zap.Error(err))
-                // We want to continue here to make sure we finish other syncs
-                // we need a better solution for this.
-                continue
-            }
+            if !retryer.ShouldWaitAndRetry(ctx, err) {
+                l.Error("max attempts reached for sync targeted resource action", zap.Any("stateAction", stateAction), zap.Error(err))
+                // Treat as non-fatal: record and drop this action so the loop can progress.
+                warnings = append(warnings, err)
+                s.state.FinishAction(ctx)
+                continue
+            }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
l.Error("max attempts reached for sync targeted resource action", zap.Any("stateAction", stateAction), zap.Error(err))
// We want to continue here to make sure we finish other syncs
// we need a better solution for this.
continue
l.Error("max attempts reached for sync targeted resource action", zap.Any("stateAction", stateAction), zap.Error(err))
// Treat as non-fatal: record and drop this action so the loop can progress.
warnings = append(warnings, err)
s.state.FinishAction(ctx)
continue
🤖 Prompt for AI Agents
In pkg/sync/syncer.go around lines 496 to 499, the code currently continues
after logging max attempts reached which leaves the SyncTargetedResourceOp on
the stack and causes infinite retries; instead call s.state.FinishAction(ctx)
before continuing to remove the action from the stack, and record a warning
(e.g., append the error and context to the action/resource warnings list or call
the existing warnings API) so the failure is tracked and counts toward the
global warning cap.

l.Warn("sync targeted resource not found, continuing to sync other resources", zap.Any("stateAction", stateAction), zap.Error(err))
s.state.FinishAction(ctx)
continue
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Unreachable Error Handling in Sync Logic

The new if block for codes.NotFound errors in partial syncs is unreachable. The preceding isWarning(ctx, err) check already handles NotFound errors and continues, preventing this specific logic from executing. The codes.Code(status.Code(err)) conversion is also redundant.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants