Publication parser returns an empty publisher after removing the unidentified-place marker
Summary
get_location_and_publisher() recognizes and removes the Place of publication not identified marker, but does not recheck whether the remaining string is empty before applying the publisher fallback.
As a result, an input consisting only of this marker returns ([], [""]) instead of ([], []).
The import API checks whether the returned publisher list is nonempty, so [""] can also propagate into the generated edition metadata as publishers=[""].
Version and environment
- Repository: https://github.com/internetarchive/openlibrary
- Checked commit:
6d66f877b83af3d4557d766f4f156165add8e405(source checked on 2026-10-25). - Linux; Python 3.14.5 and the checkout’s test requirements. The parsing checks use luqum 0.11.0. Building psycopg2 requires PostgreSQL development headers/pg_config; our reproduction environment used the same-version psycopg2-binary distribution instead.
Expected behavior
When removing the recognized unidentified-place marker leaves no valid publication information, get_location_and_publisher() should return empty location and publisher lists.
The fallback should not create an empty publisher entry from a value that explicitly indicates missing publication information.
Reproduction
Prepare a separate checkout:
git clone https://github.com/internetarchive/openlibrary.git oblitest-openlibrary
cd oblitest-openlibrary
git checkout --detach 6d66f877b83af3d4557d766f4f156165add8e405
git submodule update --init --recursive
python3.14 -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements_test.txt
export PYTHONPATH="$PWD${PYTHONPATH:+:$PYTHONPATH}"
From the checked-out repository root, save the following as reproduce.py and run python reproduce.py. It prints observations; a zero script exit status does not mean that the reported behavior is correct.
from openlibrary.plugins.upstream.utils import get_location_and_publisher
for value in ['Place of publication not identified', '', 'Paris : Example Press']:
print(repr(value), get_location_and_publisher(value))
Observed behavior
get_location_and_publisher("Place of publication not identified") returns ([], [""]).
Scope of the evidence
Actual publication helper with a single metadata string; database persistence of the empty publisher was not tested.
Relevant source
Hi @lucky20020327 i am new to open source can i work on this
Looking further through the surrounding code, I think there is stronger evidence that publishers=[""] is an unintended state rather than merely an alternative representation of a missing publisher.
The parser’s colon-handling branch explicitly removes empty publisher elements:
publishers = [item for item in publishers if item]
The fallback branch does not apply the same check, which is how an empty element escapes in this case.
The import schema also defines publishers as NonEmptyList[NonEmptyStr]. In other words, when the field is present, every publisher is expected to contain at least one character. The calling code follows the same convention: it only adds the field when the returned publisher list is truthy. An empty list therefore means “no publisher field”, while [""] incorrectly passes that condition.
This distinction has observable downstream effects. The publisher matcher treats a missing publisher as providing no evidence and assigns 0 points, whereas [""] is treated as a present value and can receive +100 because the empty string is considered a substring of every publisher name.
It also interferes with metadata repair. The contribution-task code recognizes None, "", and [] as missing values, but not [""], so an edition with this value is not offered a “Fill in publisher” task. Similarly, a nonempty list containing an empty string may be counted as having publisher information by downstream completeness logic.