Handle empty publish_place without erroring#10907
Merged
cdrini merged 1 commit intointernetarchive:masterfrom Jun 9, 2025
Merged
Handle empty publish_place without erroring#10907cdrini merged 1 commit intointernetarchive:masterfrom
cdrini merged 1 commit intointernetarchive:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
The PR prevents errors when publish_place receives an empty or whitespace-only string by returning an empty string early.
- Added a guard clause in
publish_placefor blank inputs. - Ensures the function no longer raises index errors on empty values.
Comments suppressed due to low confidence (1)
openlibrary/catalog/marc/parse.py:416
- Introduce a unit test for
publish_placeto cover cases where the input is empty or contains only whitespace, verifying that it returns an empty string without error.
if place == '':
cdrini
approved these changes
Jun 9, 2025
Collaborator
There was a problem hiding this comment.
Confirmed https://testing.openlibrary.org/import/preview?source=marc:https://archive.org/download/harvard_bibliographic_metadata/20220215_007.bib.mrc:35217684 now preview imports without issue 👍
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.
Quick fix for #10901 if the original cause is empty publication places.
Closes #10901
Technical
Testing
I was able to import the 500ing record from the issue:
https://openlibrary.org/show-records/harvard_bibliographic_metadata/20220215_007.bib.mrc:35217684:1127