fix(cloudkit): surface per-record modify errors instead of discarding them - #354
Open
MrJarnould wants to merge 1 commit into
Open
fix(cloudkit): surface per-record modify errors instead of discarding them#354MrJarnould wants to merge 1 commit into
MrJarnould wants to merge 1 commit into
Conversation
… them
CloudKit answers 200 for a modify whose records were rejected, and puts the
reason in the record entry. `CKModifyResponse.records` is already typed to
include `CKErrorItem`, but nothing looked: every caller scanned for a
`CKRecord` with a matching name, did not find one, and reported something
of its own invention.
So a rejected write surfaced as "modify response missing record", which
reads like a response-shape problem, and the only useful sentence in the
response was thrown away. Photos filters errors out with an isinstance
check; reminders does not look at all.
modify() now raises CloudKitApiError naming every rejected record with
Apple's code and reason, and carries the response as the payload.
Live proof of what this recovers. `InvitesService.rsvp()` reported "RSVP
modify response missing record". What Apple actually said was:
CONFLICT (record to insert already exists)
which is a different problem entirely, and points at its real cause.
Closes timlaing#353
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 10 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
CloudKit answers
200for a modify whose records were rejected, and puts the reason in therecord entry.
CKModifyResponse.recordsis already typedlist[CKRecord | CKTombstoneRecord | CKErrorItem], so the error is modelled — but nothinglooked at it.
Every caller scanned for a
CKRecordwith a matching name, did not find one, and reportedsomething of its own invention. Invites raised "modify response missing record", which reads
like a response-shape problem. Photos filters errors out with an
isinstancecheck. Remindersdoes not look at all — a caller ignoring the return value would see a silent no-op.
modify()now raisesCloudKitApiErrornaming every rejected record with Apple's code andreason, carrying the response as the payload.
What this recovered, immediately
InvitesService.rsvp()reported:What Apple actually said was:
An entirely different problem, and it pointed straight at the cause:
rsvp()chooses betweencreate and update by looking for the existing response in
event.rsvps, and event hydrationwas silently returning none of them. That is #350, fixed in #352. With both in place the write
takes effect — verified live on an event with no guests,
GOING→MAYBEwith a message, andback.
So the chain was: a rejected query, discarded → empty hydration → wrong operation type → a
rejected write, also discarded → a message about response shape. Two swallowed errors between
the cause and the symptom, and this PR removes the second.
Scope
Raising rather than collecting, because no caller could have been relying on partial-failure
semantics: none of the three services inspect record errors at all today, so none can
distinguish a partial success from a total one. If a future caller wants per-record outcomes
for a non-atomic batch, the payload carries the full response and the behaviour can be
widened then.
Type of change
Additional information
Cut from
main, touching onlypyicloud/common/cloudkit/client.pyandtests/test_cloudkit_client.py. Independent of my other open PRs, though it and #352 are moreuseful together.
Testing. 936 tests pass on Python 3.10, 3.11, 3.12, 3.13 and 3.14, run locally. Three are
new: a rejected record surfaces Apple's code and reason, a batch names every rejected record,
and a successful modify is unaffected.
No existing test needed changing, which is itself worth noting: nothing in the suite asserted
the old behaviour, because the old behaviour was to say nothing.
Checklist
If user exposed functionality or configuration variables are added/changed:
🤖 Generated with Claude Code