Skip to content

Full text from an OpenAlex URL is cached without checking that it is the cited paper #193

Backlog

Description

@caufieldjh

When OpenAlex points a work at the wrong document, the fetcher downloads that document and caches it as the work's full text. Nothing checks that the text belongs to the cited paper. Snippet validation is a substring match against the cached body, so a quote taken from the unrelated document would validate.

Two cases from dismech

Both were found in dismech's committed cache (monarch-initiative/dismech#7843).

DOI:10.1186/s12890-024-03371-5, Evolution of treatment strategies for solid tumors with RET rearrangement in China… (BMC Pulmonary Medicine, 2024). Cached in July 2026 as:

content_type: full_text_pdf
full_text_provider: openalex
full_text_url: "https://purehost.bath.ac.uk/ws/files/61926548/2014_02_07_Apereo_Europe_2014.pdf"

The body was conference slides: "Cope, J 2014, 'Training researchers with Sakai', Esup Day 17 & Apereo Europe 2014…". OpenAlex has since corrected the record. On 2026-12-04 it returns the BMC PDF, and a --force re-fetch with 0.8.0 cached the right article. The fetcher had no way to notice the earlier mistake, though, and OpenAlex will make others.

PMID:31922885, Diverse Injury Pathways Induce Alveolar Epithelial Cell CCL2/12, Which Promotes Lung Fibrosis (Am J Respir Cell Mol Biol, 2020). It was cached with full_text_provider: openalex and full_text_url: "https://inria.hal.science/inria-00075378", and the body was a French-language INRIA report on human–computer-interface ergonomics. dismech has since re-fetched it, and it is now abstract_only.

Why a whole-file check is not enough

The second case had the correct PubMed abstract above the wrong body. Every title word appeared in the file, so a title-overlap check over the whole cache entry passed. A check has to look at the fetched body on its own.

Suggested check

Before stamping a fetched document full_text_*, confirm that it is the cited work, using the document's own text and not the metadata or abstract the cache adds around it. Possible signals, cheapest first:

  1. The DOI appears in the body. Most publisher PDFs and HTML pages print it.
  2. Failing that, most of the normalized title appears in the first part of the body.
  3. Optionally, the body's language matches the abstract's. This would have caught the French case.

When the check fails, keep the abstract and record the decline (for example declined="identity_mismatch", beside the existing landing_page_only), rather than caching the document. That matches how landing pages are handled since #65.

Related: #65 (landing pages stamped as full text) dealt with the other failure in the same dismech report: the right paper, but no article text.

Generated by Claude Code

Activity

  1. added
    bug
    on Dec 4, 2026
  2. github-actions commented on Dec 4, 2026

    @github-actions
    Contributor

    Summary

    OpenAlex can point a DOI at the wrong document (stale or mis-merged best_oa_location.pdf_url). The fetcher downloads that file and stamps it full_text_*. Because snippet validation is a substring match against the cached body, a quote from the unrelated document would validate. dismech hit this twice (monarch-initiative/dismech#7843). The issue proposes an identity check on the fetched body alone, before the full_text_* stamp is applied. If the check fails, keep the abstract and record declined="identity_mismatch".

    Where this lands in the code (read from main)

    • etl/fulltext/openalex.py locate() returns a FullTextLocation with the PDF URL and no identity check. The only decline there is landing_page_only (Landing-page fallback is stamped full_text_html: a cache entry can claim full text while holding only the abstract #65).
    • etl/reference_fetcher.py _apply_full_text_location (~L1277) is the one place every provider's location is accepted. It already has two gates: the MIN_FULL_TEXT_CHARS floor and the "html text == abstract" check. It then writes content.content = abstract + text and stamps content_type. This is the natural spot for an identity gate, because it covers Unpaywall and custom providers as well as OpenAlex. The issue title only mentions OpenAlex, but the failure applies to any provider that follows a third-party URL.
    • The declined plumbing already exists: FullTextLocation.declined, content.full_text_declined and the loop near L1146–1216. A decline raised from the apply step needs to feed declined_on_policy, so the chain tries the next provider before giving up. Today _apply_full_text_location returns only (applied, transient_error), so it would need a third return value or a small result object.
    • text in _materialize is the body before the abstract is prepended, so the check can run on text alone. That is the "body on its own" requirement from the issue, and it is what the second case needed (right abstract above, wrong body below).

    Design notes and suggestions

    1. Make the check a pure function (for example body_matches_reference(text, doi, title, abstract) -> Optional[str] returning a reason or None). It is deterministic and easy to doctest, which fits the repo's TDD and doctest rules. The cases above become regression tests with no mocks, using the two bodies quoted in the issue as fixtures.
    2. DOI signal. Normalise case and strip https://doi.org/ and doi:. PDF extraction can break DOIs across lines or spaces, so remove whitespace in the first N and last N KB before matching. Match on the suffix as well as the full DOI, since some PDFs print only 10.1186/s12890-....
    3. Title signal. Normalise with the validator's existing normalisation (Unicode, quotes, ligatures). Compare token sets in the first ~5–10k characters. A threshold such as ≥80% of non-stopword title tokens is more robust than a contiguous substring, because titles wrap and hyphenate in PDFs.
    4. Reasoning about the combination. A DOI hit should accept. No DOI but a title hit should accept. Neither should decline. The risk is false declines on real papers: scanned or OCR'd PDFs, publisher PDFs that print neither string in the first pages, and titles that differ between Crossref and the PDF. Suggestions:
      • Log and record which signal matched (identity_check: doi|title), so false declines can be audited.
      • Search the whole body for the DOI (cheap) and limit only the title check to the head.
      • Consider a fail-open path for very short titles (<4 tokens), where the title check has no discriminating power.
    5. Language signal (optional). A lightweight stopword-ratio heuristic avoids a new dependency. It would have caught the French INRIA report. It is the weakest signal and should only break ties, not decide alone.
    6. Cached entries. Entries already cached before the fix (as dismech's were in July) will stay wrong until re-fetched. Two options: an identity-check version stamp in metadata, as with html_full_text_version and xml_extraction_version, so stale entries are re-validated on read, or a validate/lint pass over an existing cache that applies the same function to ## Content bodies and reports mismatches. The second gives dismech a way to audit its 54k-entry cache without hitting the network. The issue doesn't mention this, and it is where the fix would be most useful to existing users.
    7. Scope. The check does not apply to PMC XML or Europe PMC, where the ID resolves server-side. It matters for providers that follow third-party URLs: OpenAlex, Unpaywall and URL/custom providers.

    Related

    I could not check the dismech issue (monarch-initiative/dismech#7843) from here, so the two cases above come from this issue's text.

    If someone wants an implementation: @dragon-ai-agent please implement an identity check (DOI in body, else title-token overlap in the head of the body) in _apply_full_text_locationinetl/reference_fetcher.py, declining with full_text_declined="identity_mismatch" so the provider chain continues. Write doctests and tests first using bodies like the two dismech cases (conference slides and a French INRIA report), and add a cache-audit command that applies the same function to existing cache entries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions