Skip to content

Update edition matching query in unlink handler#12641

Merged
mekarpeles merged 4 commits into
internetarchive:masterfrom
jimchamp:update-unlink-record-query
May 8, 2026
Merged

Update edition matching query in unlink handler#12641
mekarpeles merged 4 commits into
internetarchive:masterfrom
jimchamp:update-unlink-record-query

Conversation

@jimchamp
Copy link
Copy Markdown
Collaborator

@jimchamp jimchamp commented May 6, 2026

Follows #11230
Follows #12402

I was under the incorrect assumption that every edition having an ocaid would also have an ia:{ocaid} source record. Believing that this was the case, I designed the unlink handler to fetch editions having an ocaid field that matches the ocaid included in the unlink request.

This PR updates the edition query to fetch records having an ocaid value that matches the given value, and records that have an ia: 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

Copilot AI review requested due to automatic review settings May 6, 2026 02:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ocaid and matching ia: 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.

Comment thread openlibrary/plugins/openlibrary/api.py
Comment thread openlibrary/plugins/openlibrary/api.py Outdated
jimchamp added 2 commits May 7, 2026 10:25
- 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.
@jimchamp jimchamp force-pushed the update-unlink-record-query branch from 74d6802 to 52b97d4 Compare May 7, 2026 17:31
@mekarpeles mekarpeles merged commit 41c7830 into internetarchive:master May 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants