Repository navigation
fix(persistence): make LivePrivateCKGateway.delete idempotent - #925
Merged
Merged
Conversation
#757 wave-6. delete(recordName:) threw raw CKError.unknownItem on an already-absent record — unlike its siblings (fetch returns nil, query returns [], save routes through translate). So a cross-device discard-of-already- deleted race surfaced a raw error up through SavedGameStore.deleteAbandoned. Now: catch .unknownItem → return (idempotent no-op, mirroring fetch's unknownItem branch); route every other error through Self.translate(_: recordName:) (mirroring save), unifying the gateway's error-translation contract. +2 tests: delete-absent doesn't throw (op still recorded, not short- circuited); delete-existing still removes (idempotency isn't a no-op). The non-unknownItem-still-surfaces path is covered by the existing translate tests the catch-all now calls. Verified: PersistenceKit 81 tests + swiftlint --strict clean. Dual CR: APPROVE x2 (pattern matches fetch/save verbatim; both callers want delete-absent-as- success). Live-path .unknownItem branch shares the documented "needs a real CKDatabase" unit-test ceiling as every other live-CK branch in this file. Part of #757 Co-Authored-By: Claude Fable 5 <[email protected]>
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.
What
LivePrivateCKGateway.delete(recordName:)now tolerates deleting an already-absent record (catchCKError.unknownItem→ return) and routes other errors throughSelf.translate— matching itsfetch/savesiblings.Why
#757 wave-6. delete was the only gateway op that threw raw
.unknownItem; a cross-device discard-of-already-deleted race surfaced it up throughSavedGameStore.deleteAbandoned.Verification
swiftlint --strictclean. +2 tests (delete-absent no-throw + op recorded; delete-existing still removes)..unknownItemcatch matchesfetchverbatim, catch-all matchessave; both callers want delete-absent-as-success.Part of #757
🤖 Generated with Claude Code