Repository navigation
fix(persistence): throw DuplicateCollectionNameException when adding a taken name - #385
Merged
Merged
Conversation
…a taken name addCollection returned the existing collection when another one had the name (trimmed, case-insensitive), while updateCollection threw DuplicateCollectionNameException. Apps couldn't tell a create from a no-op, so creating "Study" when "Study" existed closed the dialog with no feedback. addCollection now throws DuplicateCollectionNameException with the existing name inside the insert transaction. A rejected add triggers no sync and logs at info like the other collection rejections. Import and highlight paths write through the store and are unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mohamede1945
added a commit
to quran/mobile-sync-spm
that referenced
this pull request
Nov 6, 2026
0.1.55 includes quran/mobile-sync#385, which makes addCollection throw DuplicateCollectionNameException on a taken name. KMP-NativeCoroutines stays at 1.0.6, matching native-coroutines in mobile-sync v0.1.55. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mohamede1945
added a commit
to quran/mobile-sync-spm
that referenced
this pull request
Nov 6, 2026
* docs: document the duplicate-name error from createCollection mobile-sync's addCollection now throws DuplicateCollectionNameException when another collection has the name (quran/mobile-sync#385), so createCollection can throw MobileSyncDuplicateCollectionNameError. Adds an integration test that creating " study " when "Study" exists throws with the stored name and keeps a single Study. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(deps): update mobile-sync to 0.1.55 0.1.55 includes quran/mobile-sync#385, which makes addCollection throw DuplicateCollectionNameException on a taken name. KMP-NativeCoroutines stays at 1.0.6, matching native-coroutines in mobile-sync v0.1.55. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
mohamede1945
added a commit
to quran/quran-ios
that referenced
this pull request
Nov 6, 2026
Creating "Study" when "Study" existed closed the name alert with no feedback, because MobileSync's createCollection returned the existing collection instead of throwing. mobile-sync now throws DuplicateCollectionNameException on a taken name (quran/mobile-sync#385), which mapCollectionErrors already maps to DuplicateCollectionNameError. Both create flows (Bookmarks and the add-to-collection sheet) show that error in the name alert and keep the typed name. This documents the error on createCollection and adds regression tests for the service and both view models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mohamede1945
added a commit
to quran/quran-ios
that referenced
this pull request
Nov 6, 2026
0.4.11 ships mobile-sync 0.1.55, where createCollection throws MobileSyncDuplicateCollectionNameError when another collection has the name (quran/mobile-sync#385, quran/mobile-sync-spm#51). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mohamede1945
added a commit
to quran/quran-ios
that referenced
this pull request
Nov 7, 2026
…ion (#1272) * fix(bookmarks): show the duplicate-name error when creating a collection Creating "Study" when "Study" existed closed the name alert with no feedback, because MobileSync's createCollection returned the existing collection instead of throwing. mobile-sync now throws DuplicateCollectionNameException on a taken name (quran/mobile-sync#385), which mapCollectionErrors already maps to DuplicateCollectionNameError. Both create flows (Bookmarks and the add-to-collection sheet) show that error in the name alert and keep the typed name. This documents the error on createCollection and adds regression tests for the service and both view models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * build(deps): update mobile-sync-spm to 0.4.11 0.4.11 ships mobile-sync 0.1.55, where createCollection throws MobileSyncDuplicateCollectionNameError when another collection has the name (quran/mobile-sync#385, quran/mobile-sync-spm#51). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
When another collection already had the name (trimmed, case-insensitive),
addCollectionreturned that collection, whileupdateCollectionthrewDuplicateCollectionNameException. Apps couldn't tell a create from a no-op. On iOS, creating "Study" when "Study" existed closed the name alert with no feedback. quran/quran-ios#1272 works around this by checking the collection IDs before creating, and that check leaves a small race.Change
CollectionsRepositoryImpl.addCollection: inside the insert transaction, throwsDuplicateCollectionNameException(existing.name)whenstore.byNamefinds a row. The checks run in the same order asupdateCollection: reserved name, then length, then duplicate.QuranDataService.addCollection: no code change.mutatingCallrethrows beforetriggerSync, so a rejected add starts no sync, andisRejection()already logs this exception at info.CollectionsRepositoryandQuranDataServicenow lists the exception for add, and for update on the interface, which lacked it.CollectionStoredirectly, and sync and remote apply go throughCollectionsType.Tests
CollectionNameUniquenessTest: adding a case or whitespace variant now throws with the stored name, and only one row stays.TextScenariosTestTXT-08 and TXT-10: the second add now throws. TXT-08 still checks that the next sync posts nothing. TXT-10 still proves the leading BOM matches the same key, and it now also checks that the ideographic space is trimmed.QuranDataServiceWriteLoggingTest: a new test checks that adding a taken name logs at info and triggers no sync../gradlew jvmTest testAndroidHostTest --continue: passes.AnnotationsServiceTestsandBookmarksFeatureTestspass in local-sync mode.iosSimulatorArm64Test/macosArm64Testlocally.Consumers
CollectionNameException.Duplicate.BookmarksDaoImplCollectionRulesTest"adding a tag whose name is taken returns the existing tag" uses the real repository, so it will need updating.🤖 Generated with Claude Code