fix(open-library): guard search, details, and subject tools against non-dict payloads and register test suite
Description
In plugins/omi-open-library-app, several runtime bugs and unhandled exceptions can crash the service or fail requests:
-
Non-Dict Upstream Payload Crashes in
search_books:data = await _request_json("/search.json", params=params)assumesdatais always a dict anddata.get("docs")is always a list. If upstream returns non-dict payloads (e.g. rate limit error or proxy error page),data.getraisesAttributeError: 'str' object has no attribute 'get'. IfdocsisNone,docs[:limit]raisesTypeError: 'NoneType' object is not subscriptable. Furthermore, if any element indocsis not a dict,_format_bookraisesAttributeErrorondoc.get("title"). -
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 unhandledAttributeErrororTypeErrorcrashes on unexpected or malformed API responses. -
Non-Dict Upstream Payload Crashes in
search_subject:data = await _request_json(f"/subjects/{encoded_slug}.json")assumesdatais a dict andworksis a list. Non-dict responses orNoneworks cause fatalAttributeErrororTypeErrorcrashes. Malformed elements inworksor non-listauthorsalso crash_format_subject_work. -
Missing Manifest Registration & Hermetic Standard Library Test Suite: The existing
test_main.pylacked coverage forsearch_booksandget_book_details, depended on third-party test runners, and was not registered in.github/checks-manifest.yaml. A 100% hermetic unit test suite runnable viapython -m unittestwith stdlib stubs is needed and should be registered in.github/checks-manifest.yaml.
Bounty Payout Destination (Base USDC / EVM): 0xb5aFc89b57Fa8270bB7261348179D28099BEa2a0
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.
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! 🙏