Skip to content

Handle empty publish_place without erroring#10907

Merged
cdrini merged 1 commit intointernetarchive:masterfrom
hornc:master
Jun 9, 2025
Merged

Handle empty publish_place without erroring#10907
cdrini merged 1 commit intointernetarchive:masterfrom
hornc:master

Conversation

@hornc
Copy link
Collaborator

@hornc hornc commented Jun 8, 2025

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

Importing to http://localhost:8080
ITEM: harvard_bibliographic_metadata
FILENAME: 20220215_007.bib.mrc
harvard_bibliographic_metadata/20220215_007.bib.mrc:35217684:5: 200 -- {'authors': [{'key': '/authors/OL12A', 'name': '滕昕雲', 'status': 'created'}], 'success': True, 'edition': {'key': '/books/OL11M', 'status': 'created'}, 'work': {'key': '/works/OL3W', 'status': 'created'}, 'next_record_offset': 35218811, 'next_record_length': 896}

image

Copilot AI review requested due to automatic review settings June 8, 2025 23:49
Copy link
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

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_place for 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_place to cover cases where the input is empty or contains only whitespace, verifying that it returns an empty string without error.
if place == '':

@hornc hornc added the Module: Import Issues related to the configuration or use of importbot and other bulk import systems. [managed] label Jun 9, 2025
Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

@cdrini cdrini merged commit 662a34d into internetarchive:master Jun 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module: Import Issues related to the configuration or use of importbot and other bulk import systems. [managed]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

500 errors when MARC importing certain records

2 participants