Resolve #313: paginationLimitExceeded carries accumulated records#326
Conversation
When `queryAllRecords` and `fetchAllRecordChanges` hit their `maxPages` cap, they previously threw an error that dropped the partial result on the floor (either `paginationLimitExceeded(recordsCollected: Int)` or a bare `.invalidResponse`). Callers had to retry from scratch or accept silent data loss. The case now carries `records: [RecordInfo]` so callers can pattern- match the error and recover everything collected before the cap. * `CloudKitError.paginationLimitExceeded(maxPages:records:)` replaces the count-only payload. `errorDescription` keeps the same human-readable shape via `records.count`. * `queryAllRecords` throws with `records: allRecords`. Docstring corrected (it used to claim the throw was `.invalidResponse`). * `fetchAllRecordChanges` gains an explicit `maxPages:` parameter (default 1 000, was a hard-coded local) and throws the same case on overflow. * New tests under `CloudKitServiceQueryPagination/+ErrorCases.swift` and `CloudKitServiceFetchChanges/+ErrorHandling.swift` drive overflow with `maxPages: 2` and assert the carried records. * ReleaseNotes flags the breaking case-shape change under v1.0.0-beta.1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Code Review: PR #326 —
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v1.0.0-beta.1 #326 +/- ##
==================================================
+ Coverage 51.25% 69.45% +18.19%
==================================================
Files 128 529 +401
Lines 3533 14457 +10924
==================================================
+ Hits 1811 10041 +8230
- Misses 1722 4416 +2694
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…Changes * ReleaseNotes: the v1.0.0-beta.1 section is a list of auto-generated per-PR titles; the free-form "Breaking" bullet didn't fit the format. PR #326's description carries the breaking-change note. * `fetchAllRecordChanges`: switch from `while moreComing` (seeded with a throwaway `true`) to `repeat..while moreComing`, matching the sibling `queryAllRecords` in `CloudKitService+QueryPagination.swift`. Behaviorally identical. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code ReviewOverviewThis PR resolves a real usability gap: when auto-paginating helpers hit Breaking Change
Loop Refactor in
|
| Area | Verdict |
|---|---|
| Correctness | ✅ Both loop refactor and error propagation are correct |
| Breaking change | |
| Memory | ℹ️ Expected tradeoff, worth a note in release notes |
| Tests | ✅ Cover the new path with precise assertions |
| Docs | ✅ Accurate and consistent |
Overall this is a solid, well-scoped change. The one concrete suggestion: add a short comment in the new test explaining why both pages emit record-0 … record-N (per-page generation resets the counter), so future readers don't flag it as a copy-paste error.
🤖 Generated with Claude Code
Summary
Resolves #313 ("MaxPage Error Should Return Results too."), which spun out of review comment #r3210049916 on
queryAllRecords. When MistKit's auto-paginating helpers hit theirmaxPagescap, they used to throw an error that dropped the partial result. Callers had to start over or accept silent data loss. Now the error carries every record collected before the cap so callers can resume or surface partial results.CloudKitError.paginationLimitExceeded: case shape changes from(maxPages: Int, recordsCollected: Int)to(maxPages: Int, records: [RecordInfo]).errorDescriptionkeeps the same wording viarecords.count.queryAllRecordsthrows withrecords: allRecords. Docstring corrected — it previously claimed the throw was.invalidResponse.fetchAllRecordChangesgains an explicitmaxPages:parameter (default 1 000, was a hard-coded local) and now throws.paginationLimitExceededon overflow instead of.invalidResponse. Existing callers continue to work —maxPagesis defaulted.CloudKitServiceQueryPagination/+ErrorCases.swiftandCloudKitServiceFetchChanges/+ErrorHandling.swiftdrive the overflow path withmaxPages: 2and assert the carried records.ReleaseNotes.mdflags this under v1.0.0-beta.1.The PR #298 review (which inspired the work) was largely addressed in commit 7a5da7a already; verified by reading the current files. The one nit left was the
queryAllRecordsmaxPagesdocstring claiming.invalidResponse— fixed here next to the code change.Test plan
swift buildfrom repo root — clean (only pre-existing import warnings)swift test— 483 MistKit tests pass (incl. two new overflow tests)cd Examples/MistDemo && swift test— 901 tests passcd Examples/CelestraCloud && swift build— clean (its.paginationLimitExceededswitch case has no value bindings, so the shape change is invisible)cd Examples/BushelCloud && swift build— clean./Scripts/lint.sh— passes🤖 Generated with Claude Code
Perform an AI-assisted review on