omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty] Fix Semantic Scholar null payload TypeErrors, author paper sort crash, and missing identifier normalization ( proposed)

Open Ivansky1 opened this issue 2 months ago • 0 comments

Description

In plugins/omi-semantic-scholar-app/main.py, several edge cases in upstream Semantic Scholar Graph API responses cause unhandled Python exceptions and 500 server errors for Omi chat tools:

  1. TypeError: 'NoneType' object is not iterable on empty searches: When Semantic Scholar returns {"data": null}, data.get("data", []) resolves to None. The subsequent for i, paper in enumerate(papers, start=1) raises an unhandled TypeError.

  2. TypeError: '<' not supported between instances of 'str' and 'int' during author paper sorting: get_author_papers sorts papers using key=lambda p: ((p.get("year") or 0), (p.get("citationCount") or 0)). Because upstream JSON payloads may return publication years as strings (e.g. "2023"), integers (2023), or None (0), Python 3 raises an unhandled TypeError when comparing tuples with mismatched types.

  3. TypeError & AttributeError in format_authors: If a paper record has authors: null or contains non-dict elements, format_authors raises TypeError: 'NoneType' object is not iterable or AttributeError: 'str' object has no attribute 'get'.

  4. Missing DOI and URL normalization in normalize_identifier: The Semantic Scholar Graph API requires DOIs to be prefixed with DOI: (e.g. DOI:10.1038/nature12373). When users or LLM agents provide standard raw DOIs (e.g. 10.1038/nature12373) or full URLs (https://doi.org/..., https://arxiv.org/abs/...), the endpoint fails with a 404 because the prefix is missing or the URL scheme is unstripped.

  5. Missing Hermetic Unit Tests: The omi-semantic-scholar-app plugin previously lacked any unit tests, preventing automated regression detection in CI.


Proposed Fix

  • Ensure null-safe list defaults for data.get("data") and data.get("papers").
  • Implement _paper_sort_key returning a normalized tuple[int, int] for (year, citationCount) to guarantee stable sorting across heterogeneous data.
  • Add null and dict type guards to format_authors and parse numeric string years in format_year.
  • Normalize raw DOIs, DOI URLs, arXiv URLs/prefixes, and standard namespaces in normalize_identifier.
  • Broaden httpx.HTTPError handling to report clean error messages instead of uncaught 500s.
  • Add a comprehensive hermetic test suite (test_main.py) with stdlib stubs that executes with 100% pass rate in clean environments, and register it in .github/checks-manifest.yaml.

Proposed Bounty Reward: $40.00 USD / USDC (matching established plugin bug fix bounties) Receiving EVM Wallet Address (Base): 0xb5aFc89b57Fa8270bB7261348179D28099BEa2a0

Ivansky1 avatar Sep 14 '26 21:09 Ivansky1