fix(add_book): use _data.pop to strip infobase metadata from matched author - #13032
Merged
mekarpeles merged 1 commit intoJul 6, 2026
Conversation
Collaborator
|
Thank you @TechGenius-Karan for this PR! 🤖 Copilot has been assigned for an initial review. The linked issue hasn't been triaged yet — triage happens on Mondays and Fridays. There are currently 99 open non-draft PRs in the review queue. PR triage checklist (maintainers)
Note This comment was automatically generated by PAM, Open Library's Project AI Manager. PAM provides status visibility, performs basic project management functions, and gives actionable feedback so contributors aren't left waiting. |
This was referenced Jul 6, 2026
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.
Closes #13016
**Fix**The metadata cleanup loop in
author_import_record_to_author()was broken in two ways:existing.kaccessed a literal attribute named"k"(alwaysNothing/falsy) instead of the loop variablek,so the condition was never
True.del existing[k]raisesAttributeErrorbecause InfogamiThingobjectshave no
__delitem__.Fix: use
existing._data.pop(k, None)to remove the metadata keys (last_modified,id,revision,created)directly from the underlying data dict, which is the only supported mutation path on a
Thing.Technical
Thing.__setitem__delegates toself._getdata()[key], but there is no__delitem__— mutation must go through_datadirectly.mock_site.save()helper automatically appendsrevision,last_modified, andcreatedto every saveddocument, so tests that return a matched author exercised this code path in CI.
Testing
Run the affected test file:
pytest openlibrary/catalog/add_book/tests/test_load_book.py -v
All 35 tests should pass, including the new
test_infobase_metadata_keys_stripped_from_existing_authorwhichdirectly verifies that
last_modified,revision, andcreatedare absent from the returned author when a matchis found.
Before this fix, 7 tests in that file failed with
AttributeError: __delitem__wheneverfind_entity()returneda match. All now pass.
Screenshot
N/A — no UI changes.
Stakeholders