omi icon indicating copy to clipboard operation
omi copied to clipboard

fix(open-library): guard search, details, and subject tools against non-dict payloads and register test suite

Open Ivansky1 opened this issue 2 months ago • 2 comments

Description

In plugins/omi-open-library-app, several runtime bugs and unhandled exceptions can crash the service or fail requests:

  1. Non-Dict Upstream Payload Crashes in search_books: data = await _request_json("/search.json", params=params) assumes data is always a dict and data.get("docs") is always a list. If upstream returns non-dict payloads (e.g. rate limit error or proxy error page), data.get raises AttributeError: 'str' object has no attribute 'get'. If docs is None, docs[:limit] raises TypeError: 'NoneType' object is not subscriptable. Furthermore, if any element in docs is not a dict, _format_book raises AttributeError on doc.get("title").

  2. Non-Dict Upstream Payload Crashes in get_book_details: In both ISBN lookup (/api/books) and work lookup (/works/{work_id}.json), returned payloads and nested author/publisher/subject lists are accessed without type guards, causing unhandled AttributeError or TypeError crashes on unexpected or malformed API responses.

  3. Non-Dict Upstream Payload Crashes in search_subject: data = await _request_json(f"/subjects/{encoded_slug}.json") assumes data is a dict and works is a list. Non-dict responses or None works cause fatal AttributeError or TypeError crashes. Malformed elements in works or non-list authors also crash _format_subject_work.

  4. Missing Manifest Registration & Hermetic Standard Library Test Suite: The existing test_main.py lacked coverage for search_books and get_book_details, depended on third-party test runners, and was not registered in .github/checks-manifest.yaml. A 100% hermetic unit test suite runnable via python -m unittest with stdlib stubs is needed and should be registered in .github/checks-manifest.yaml.


Bounty Payout Destination (Base USDC / EVM): 0xb5aFc89b57Fa8270bB7261348179D28099BEa2a0

Ivansky1 avatar Sep 14 '26 21:09 Ivansky1

Submitted PR #13943 with complete null-safety guards across all Open Library endpoints, formatters, and search slicing, backed by a 16-test hermetic test suite and manifest registration.

shitobu avatar Sep 14 '26 21:09 shitobu

Thanks for putting this together. We aren't doing bounties at the moment, so we're closing the bounty proposal issues for now — thanks for the fix! 🙏

aryanorastar avatar Nov 05 '26 16:11 aryanorastar