#14585·omi

[Bounty proposal] fix(semantic-scholar): URL normalization, null limit coercion, and connection pooling ($25 proposed)

Author: onlymrneoCreated Sep 18, 2026Updated Sep 18, 2026

Summary

In plugins/omi-semantic-scholar-app, several input edge cases and connection lifecycle gaps degrade chat tool execution:

  1. Semantic Scholar Paper & Author URLs Fail Lookup:

    • normalize_identifier handles doi.org/ and arxiv.org/ URLs, but does not recognize semanticscholar.org/paper/ URLs (e.g. https://www.semanticscholar.org/paper/Attention-Is-All-You-Need-Vaswani/204e3073870fae3d05bcbc2f6a8e263c9b72e776 or https://semanticscholar.org/paper/204e3073870fae3d05bcbc2f6a8e263c9b72e776).
    • The raw URL string is quoted and forwarded to the Graph API path /paper/https%3A//..., returning 404 "Paper not found".
    • get_author_papers lacks URL normalization entirely: providing an author profile URL (https://www.semanticscholar.org/author/A.-Vaswani/1741101) or author: 1741101 fails with 404.
  2. Query Parameters, Fragments, and Enclosing Quotes Corrupt Upstream Queries:

    • Browser-copied URLs often retain query strings (e.g. ?utm_source=chat) or fragments (#abstract, #citations). These are currently appended directly to the paper/author path segments, resulting in upstream 404 errors.
    • Quoted inputs (e.g. "10.1038/nature12373", <https://arxiv.org/abs/...>) are not stripped before prefixing.
  3. Backend null for Omitted Optional Parameters Triggers 422 Unprocessable Entity:

    • In models.py, SearchPapersRequest.max_results and GetAuthorPapersRequest.max_results are typed int rather than Optional[int].
    • When the backend sends explicit JSON null for omitted optional fields (e.g. {"query": "attention", "max_results": null}), Pydantic raises a 422 validation error instead of defaulting to 5.
  4. Lack of HTTP Client Lifespan Connection Pooling:

    • api_get instantiated a fresh httpx.AsyncClient on every tool invocation, creating socket churn and connection overhead under consecutive queries.

Proposed Fix

  1. Full URL & Target Normalization:
    • Add regex extraction for semanticscholar.org/paper/ paths to extract the 40-character hex SHA or CorpusId.
    • Implement normalize_author_id to extract author IDs from profile URLs and author: prefixes.
    • Strip query strings (?), fragments (#), and wrapping quotes/brackets.
  2. Defensive Model Coercion:
    • Make max_results Optional[int] in request models and clamp/default None or invalid types to 5.
  3. Lifespan Connection Pooling:
    • Implement FastAPI lifespan context manager storing app.state.client, while preserving a graceful fallback client for unmanaged test contexts.
  4. Hermetic Regression Test Suite:
    • Expanded hermetic test suite in plugins/omi-semantic-scholar-app/test_main.py from 46 to 60 tests covering all new normalization patterns, null coercions, and URL targets. All 60 tests pass in 0.07s.

Bounty Proposal ($25)

  • Proposed Bounty: $25.00 USD (consistent with recent plugin reliability bounties)
  • Payout Destination (Bitcoin / BTC): bc1q3yjwx8s6mupuysh5p2ystvrtu8un5r0w9nxgn6
  • PR Status: Ready for immediate submission with hermetic regression tests.

cc @josancamon19 @kodjima33