Repository navigation
Skip records with unparseable XML instead of failing ListRecords - #90
Merged
Merged
Conversation
pyoai only calls the metadata writers once the catalog has returned every record on the page, so one record whose stored XML can't be parsed turned the whole ListRecords response into a 500 and harvesters could never get past that page. For the datacite and oai_datacite formats, parse the XML while building each record's metadata map. ListRecords now skips (and logs) a record that can't be parsed and keeps the resumption token. GetRecord returns a cannotDisseminateFormat OAI error for it. oai_dc doesn't use the stored XML and is unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 of 5 tasks
wendelfabianchinsamy
approved these changes
Nov 24, 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.
Purpose
Follow-up to #86 for datacite/datacite#2570. It's stacked on #86, so please merge #86 first. GitHub will then retarget this PR to
master.#86 makes the reported DOI work by stripping XML-invalid characters from UTF-8 records. Some stored XML will still fail to parse for other reasons, such as broken markup or bad entities. pyoai only calls the metadata writers once the catalog has returned every record on the page, so one bad record turns the whole ListRecords response into a 500. A harvester working through that set can never get past that page.
Approach
dataciteandoai_dataciteformats,build_metadata_mapnow parses the stored XML for active records. The parsed element goes into the map, and the writers reuse it.logging.error, which Sentry's default logging integration reports along with the DOI. The resumption token is kept, so harvesting continues.cannotDisseminateFormaterror for that record instead of a 500.oai_dcdoesn't use the stored XML. Deleted records still show only their header.Open Questions and Pre-Merge TODOs
completeListSizestill counts skipped records. The OAI-PMH spec treats that number as an estimate.noRecordsMatch. We think that's unlikely to happen in practice.Learning
Lupo should still clean or reject C0 control characters when metadata is written, and existing affected DOIs should be repaired. That is tracked separately from this repo.
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Tests
New integration tests in
tests/integration/test_oai.pycover both XML formats:cannotDisseminateFormatfor the bad record.oai_dcstill serves a record whose XML can't be parsed.43 tests pass with
pytest -m "not real". Codex reviewed the change and reported no material findings.Reviewer, please remember our guidelines:
🤖 Generated with Claude Code