Invalid publication years displayed for books
Problem
Open Library is displaying clearly invalid publication years for multiple books.
For example, search results currently show:
- Sechs Sonaten für Klavier allein. —
First published in 8858 - Die Schöpfung: Oratorium. —
First published in 7619 - Ouverturen von Boieldieu, Auber, Herold, Spontini. —
First published in 6621 - Konzertstücke. —
First published in 6223
These values are not plausible publication years and appear to be affecting multiple unrelated records rather than a single book.
The issue is also visible on individual edition pages. For example, the edition page for Der endemische Kretinismus (Pathologie und Klink in Einzeldarstellungen) -> link. displays 2036 as its Publish Date.
This can mislead users, makes search results unreliable, and may also affect functionity that depends on publication-year metadata such as sorting, filtering, or displaying "First published" information.
Screenshots attached to this issue show the invalid years in Open Library search results and on an edition page.
The Der endemische Kretinismus (Pathologie und Klink in Einzeldarstellungen). edition is particularly useful for reproduction because the invalid 2036 value is visible on the edition page itself, not only in the search-result summary. while the same book when click on located and seen on world cat shows completely different dates.
Reproducing the bug
- Go to Open Library.
- login to Open Library.
- Search for
c++and apply filtersort by-most recent- direct link - Search for a book with affected publication metadata, for example
Die Schöpfung: Oratorium-> direct link . - Observe the publication year shown in the search results.
- Open the affected edition.
- Observe the Publish Date on the edition page.## Behavior
Behavior
- Expected behavior: Open Library should display the actual publication year when reliable publication metadata is available. If the publication year cannot be determined reliably, it should not display an obviously invalid year.
- Actual behavior: Open Library displays implausible four-digit values such as 8858, 7619, 6621, and 6223 as publication years. In some cases, the same invalid value is also displayed as the edition's Publish Date.
Context
- Browser (Chrome, Safari, Firefox, etc): Brave
- OS (Windows, Mac, etc): Fedora
- Logged in (Y/N): Y
- Environment (prod, dev, local): prod
Breakdown
Implementation Details (for maintainers)
Requirements Checklist
- [ ]
Related files
Stakeholders
Instructions for Contributors
- Please run these commands to ensure your repository is up to date before creating a new branch to work on this issue and each time after pushing code to Github, because the pre-commit bot may add commits to your PRs upstream.
small update:
I traced the incorrect Publish Date from the template to the MARC import logic.
I have attached a screenshot of the MARC record.
In openlibrary/templates/type/edition/view.html, the page displays edition.publish_date. In openlibrary/catalog/marc/parse.py, publish_date is populated from characters 7–10 of the MARC 008 field:
publish_date = f[7:11]
For the affected Miami University of Ohio record, these characters contain 8858, so Open Library stores and displays 8858 as the publication date.
However, the same MARC record contains:
260 $c[n.d.] Pl. no. 8858
Here, [n.d.] means "no date", indicating that the publication date is not provided. Pl. no. 8858 refers to a plate number, not a publication year.
At this point, there are two possibilities:
- The source MARC data contains an incorrect value in the
008date position. - If the source data is correct then the importer needs additional handling/validation for this type of record.
I haven't made any code changes yet and waiting for Staff Discussion.
I think the problem is in the read_edition function in parser.py the f[6] flag is responsible for describing the rest of the structure (reprint, copyright ). But the 'if' condition for checking the flag is executed after storing the value. Therefore the garbage value stays and we get values like 8858.
For cases like f[6] == "q", the garbage value in f[7:11] (e.g. 8858) gets stored in step 1, the f[6] checks in steps 2–3 don't match, and the 260$c fallback in step 4 never fires because publish_date is already set.
Proposed Fix
Gate the publish_date assignment behind an f[6] validity check:
publish_date = f[7:11]
VALID_DATE1_TYPES = {"s", "r", "t", "e", "p", "c", "d"}
# Only store if f[6] says date1 is meaningful
if f[6] in VALID_DATE1_TYPES and re_date.match(publish_date) and publish_date not in ("0000", "9999"):
edition["publish_date"] = publish_date
if f[6] == "r" and f[11:15] > publish_date:
update_edition(rec, edition, read_pub_date, "publish_date")
elif f[6] == "t":
edition["copyright_date"] = f[11:15]
#Now this fallback correctly triggers for "q", "n", "u"
if "publish_date" not in edition:
update_edition(rec, edition, read_pub_date, "publish_date")
This makes the existing 260$c fallback (line 696–697) actually reachable for all the unhandled f[6] cases instead of silently storing an invalid year.
Should i start a pull request?
We already have a rule in place to prevent future dates within our importer. I'm not opposed to stricter rules preventing any future date, I think @cdrini may prefer it being up to the discretion of humans/librarians (noting my disagreement but not making a call). Were we are agreed for now is closing this issue and leaving it to the librarians, since the volume of infracting editions is <500
@CipherZ3r0 It's much easier for people to work with links and text than pictures, viz
Sechs Sonaten für Klavier allein - edition - https://openlibrary.org/books/OL16642095M
MARC record - https://openlibrary.org/show-records/marc_miami_univ_ohio/allbibs0038.out:7022828:952
MARC 260 field - 260 0 $aLeipzig,$bC. F. Peters$c[n.d.] Pl. no. 8858
@Ved-sketch The same applies to using live permalinks to the code instead of a picture of it
https://github.com/internetarchive/openlibrary/blob/726c1fdd4cb8970c239a3bbd93ac683f364a7525/openlibrary/catalog/marc/parse.py#L689-L697
@hornc The presence of [n.d.], [s.n.], [no date], etc in the 260$c subfield should be a strong indicator to not attempt to parse it as a date. If there aren't already tests that cover this, it would be a useful addition.
@tfmorris Thank you for the guidance! I'm a newbie to open-source, and learning these best practices is super helpful. Since the team decided to close this specific issue, I won't be submitting a PR for it, but I will make sure to use live permalinks for all my future contributions.