Skip to content

[Bounty proposal] fix(pubmed): handle missing summaries, normalize URL targets, and add test suite ($25 proposed) #14552

Closed

Description

@onlymrneo

Problem Statement

  1. False Success on Missing/Deleted PMIDs:
    In plugins/omi-pubmed-app/main.py, get_pubmed_article previously checked if pmid not in summaries: to detect missing articles. However, when querying a non-existent or deleted PMID (e.g. 999999999), NCBI ESummary returns HTTP 200 with {"result": {"uids": ["999999999"], "999999999": {"uid": "999999999", "error": "cannot get document summary"}}}.
    Because pmid in summaries evaluates to True, _extract_article_fields was executed on the error dict, returning a successful ChatToolResponse with Title: Untitled and empty metadata instead of reporting an error.

  2. Rejection of Valid PubMed URLs and Formatted Identifiers:
    Users and chat agents commonly paste full PubMed article URLs (e.g., https://pubmed.ncbi.nlm.nih.gov/34567890/ or https://www.ncbi.nlm.nih.gov/pubmed/34567890) or formatted strings (PMID: 34567890). _is_valid_pmid strictly enforced .isdigit(), rejecting valid pasted links with pmid must be a numeric PubMed ID.

  3. Defensive Parsing:
    _extract_article_fields and search result enumerations did not guard against error rows or heterogeneous author structures in NCBI payloads.

  4. Missing Test Coverage:
    The app previously lacked a dedicated endpoint test suite (test_main.py) for FastAPI routes, manifest integrity, and parameter validation.

Proposed Solution

  • Added _normalize_pmid to cleanly extract numeric PMIDs from URLs, PMID: prefixes, and whitespace.
  • Updated get_pubmed_article, search_pubmed, and get_related_pubmed to verify record_data and explicitly handle NCBI {"error": ...} summaries.
  • Added comprehensive hermetic test suite in plugins/omi-pubmed-app/test_main.py (22 unit & endpoint tests, 0 external network dependencies).

@josancamon19 @kodjima33 — proposing $25 bounty reward per the contribution guidelines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions