Skip to content

fix: batch CloudKit push to respect 400-item limit#342

Merged
datlechin merged 1 commit intomainfrom
fix/cloudkit-sync-batch-push
Mar 16, 2026
Merged

fix: batch CloudKit push to respect 400-item limit#342
datlechin merged 1 commit intomainfrom
fix/cloudkit-sync-batch-push

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

@datlechin datlechin commented Mar 16, 2026

Summary

  • CloudKit's CKModifyRecordsOperation has a 400-item (saves + deletions) limit per request
  • When syncing >400 records (e.g., 520 connections/history items), the push fails with "Your request contains N items which is more than the maximum number of items in a single request (400)"
  • Split push into batches of 400 items, filling saves first then deletions with remaining capacity

Test plan

  • Trigger a sync with >400 pending records and verify it completes without error
  • Verify normal syncs (<400 items) still work as before

Summary by CodeRabbit

  • Bug Fixes
    • Improved CloudKit synchronization reliability and performance when syncing large numbers of items at once.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 16, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

CloudKitSyncEngine's push method now batches operations in chunks of 400 items to comply with CloudKit's per-modify request limit. The implementation splits saves and deletions into separate batches, processes them sequentially, and consolidates logging after all batches complete.

Changes

Cohort / File(s) Summary
CloudKit Batch Processing
TablePro/Core/Sync/CloudKitSyncEngine.swift
Added maxBatchSize constant (400), batch splitting logic for saves and deletions, iterative batch processing via pushBatch, and relocated final logging to execute after all batches are processed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hundred bunches of four hundred each,
CloudKit's limit within reach,
Batch by batch, we hop along,
Splitting saves, making sync strong!
One log to rule them all at the end, 🌙

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: implementing batching in CloudKit push operations to respect the 400-item limit.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/cloudkit-sync-batch-push
📝 Coding Plan
  • Generate coding plan for human review comments

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

@datlechin datlechin merged commit 264d2e1 into main Mar 16, 2026
2 of 3 checks passed
@datlechin datlechin deleted the fix/cloudkit-sync-batch-push branch March 16, 2026 10:26
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.

1 participant