[Bounty] Fix Semantic Scholar null payload TypeErrors, author paper sort crash, and missing identifier normalization ( proposed)
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:
-
TypeError: 'NoneType' object is not iterableon empty searches: When Semantic Scholar returns{"data": null},data.get("data", [])resolves toNone. The subsequentfor i, paper in enumerate(papers, start=1)raises an unhandledTypeError. -
TypeError: '<' not supported between instances of 'str' and 'int'during author paper sorting:get_author_paperssorts papers usingkey=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), orNone(0), Python 3 raises an unhandledTypeErrorwhen comparing tuples with mismatched types. -
TypeError&AttributeErrorinformat_authors: If a paper record hasauthors: nullor contains non-dict elements,format_authorsraisesTypeError: 'NoneType' object is not iterableorAttributeError: 'str' object has no attribute 'get'. -
Missing DOI and URL normalization in
normalize_identifier: The Semantic Scholar Graph API requires DOIs to be prefixed withDOI:(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. -
Missing Hermetic Unit Tests: The
omi-semantic-scholar-appplugin previously lacked any unit tests, preventing automated regression detection in CI.
Proposed Fix
- Ensure null-safe list defaults for
data.get("data")anddata.get("papers"). - Implement
_paper_sort_keyreturning a normalizedtuple[int, int]for(year, citationCount)to guarantee stable sorting across heterogeneous data. - Add null and dict type guards to
format_authorsand parse numeric string years informat_year. - Normalize raw DOIs, DOI URLs, arXiv URLs/prefixes, and standard namespaces in
normalize_identifier. - Broaden
httpx.HTTPErrorhandling 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