Fix SAX parser state leakage for PubmedBookArticle#106
Open
paulalbert1 wants to merge 2 commits intomasterfrom
Open
Fix SAX parser state leakage for PubmedBookArticle#106paulalbert1 wants to merge 2 commits intomasterfrom
paulalbert1 wants to merge 2 commits intomasterfrom
Conversation
…icle The SAX parser uses a single instance-level `pubmedArticle` variable. When PubMed returns a batch containing both <PubmedArticle> and <PubmedBookArticle> elements, there was no handler for <PubmedBookArticle>. When a book article followed a regular article, `pubmedArticle` still referenced the previous article, causing the book article's AuthorList, Abstract, and other fields to overwrite the previous article's data. This corrupted data would then be saved to DynamoDB. For example, PMID 38461731 had its 8-author list replaced by 79 authors from book article PMID 41525446. Fix: null out `pubmedArticle` when <PubmedBookArticle> is encountered, so all subsequent element processing is skipped by the existing `if (pubmedArticle != null)` guard. Also remove a duplicate AuthorList handler block in startElement that re-initialized the author list unnecessarily. This is a short-term fix; long-term plan is to properly parse and support PubmedBookArticle types. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix SAX parser state leakage when PubmedBookArticle follows PubmedArticle
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.
Summary
Fixes a bug where
PubmedBookArticleelements in PubMed eFetch responses corrupt the previously-parsedPubmedArticlerecord's data (author list, abstract, etc.) via SAX parser state leakage.Changes
pubmedArticlewhen<PubmedBookArticle>is encountered — prevents book article fields from overwriting the previous article's dataAuthorListhandler block — identical code appeared twice instartElementRoot Cause
PubmedEFetchHandler.javauses a singlepubmedArticleinstance variable. When a<PubmedBookArticle>follows a<PubmedArticle>in the same batch, no new object is created — so the book article's AuthorList, Abstract, etc. overwrite the previous article via the still-live reference.Impact
Verified on dev
Merged to dev via PR #105 and deployed.
After merge to master
Re-retrieve articles for affected users with
refreshFlag=ALL_PUBLICATIONSto replace corrupted DynamoDB records.Long-term
Proper PubmedBookArticle parsing is planned as a separate effort (see MULTI_SOURCE_ARCHITECTURE.md in scoring research repo).