Update edition matching query in unlink handler#12641
Merged
mekarpeles merged 4 commits intoMay 8, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the /api/unlink web.py handler so it can find IA-linked editions by either the edition ocaid field or an ia:{ocaid} entry in source_records, matching how IA/Open Library links are represented across the codebase.
Changes:
- Expands the unlink lookup to query editions by both
ocaidand matchingia:source records. - Updates the unlink mutation path to avoid raising when an affected edition is missing an
ocaid. - Keeps the handler focused on darkening/removing the requested IA association from the matched edition.
- Deduplicate edition keys - Delete `ocaid` only if it matches given ocaid
Multiple edition records may share the same ocaid or `ia:*` source record. Instead of returning `409` when more than one edition is found, we update all matching editions.
74d6802 to
52b97d4
Compare
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.
Follows #11230
Follows #12402
I was under the incorrect assumption that every edition having an
ocaidwould also have ania:{ocaid}source record. Believing that this was the case, I designed the unlink handler to fetch editions having anocaidfield that matches the ocaid included in the unlink request.This PR updates the edition query to fetch records having an
ocaidvalue that matches the given value, and records that have ania:source record that contains the given ocaid.The unlink code has also been updated to handle linked records that are missing ocaids without error.
Technical
Testing
Screenshot
Stakeholders