Repository navigation
fix(crossref-app): connection pooling, null/non-dict payload guards, and hermetic test suite (fixes #13978) - #14178
Conversation
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @arawnslab-hash — the core of this is solid, well-scoped work, and I verified it: the new suite passes 5/5 locally and the payload guards close the crash paths from #13978. One blocking regression before merge, plus smaller notes.
What's good (verified in plugins/omi-crossref-app/main.py):
- The lifespan-managed httpx.AsyncClient with the per-request fallback in crossref_get() (client = getattr(getattr(app, "state", None), "client", None); is_closed check) is the right pooling pattern and keeps the module usable outside a running app.
- The null/non-dict guards in search_crossref_works, get_crossref_work, and get_crossref_works_by_author (message = data.get("message"); items = message.get("items", []) if isinstance(message, dict) else []) fix every AttributeError path named in the issue, and extract_year's isinstance checks close the date-parts IndexError case.
- test_crossref.py is genuinely hermetic (httpx/fastapi/models stubbed, no network) and green.
Blocking — clean() drops the JATS/HTML stripping from #13525 (merged Sep 12). main's clean() removed jats:* and generic HTML tags before text reaches chat output; this PR's version only unescapes entities and collapses whitespace. On a typical Crossref abstract like jats:pWe report x < 0.5 in jats:italicDrosophila</jats:italic>...</jats:p>, get_crossref_work now returns the raw markup in the Abstract field (verified by running both implementations side by side). The PR description doesn't mention this removal. Please restore the _JATS_TAG/_CLOSE_TAG/_OPEN_TAG stripping — keeping your whitespace normalization is fine — and add one regression test with a JATS-marked abstract; the new suite has no clean()-on-tagged-input coverage, which is why this slipped through.
Non-blocking:
- The isinstance(data, dict) guards after crossref_get() are unreachable through the real seam (crossref_get already returns {} for non-dict JSON); only the mocked tests hit them. Fine as defense-in-depth, but worth a comment saying so.
- Every test patches crossref_get itself, so the new pooling/fallback path has zero coverage — a broken is_closed or fallback branch would not be caught.
- TIMEOUT changed 20s total to 15s total / 5s connect via httpx.Timeout. Looks intentional; flagging for visibility.
- The suite isn't wired into any CI lane: no checks-manifest entry or workflow discovers plugins/omi-crossref-app tests, though #13978 explicitly asked for manifest registration. Note #13979 (open, same issue) includes that registration, so maintainers will want to coordinate rather than land both.
Once the tag-stripping is restored with a regression test, I have no further code concerns.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Hi @Git-on-my-level, Thank you for the detailed review and catch regarding the JATS/HTML stripping behavior from #13525! All requested changes have been applied in commits
Ready for your re-review! 🙏 |
4b6bd7f to
d3819b7
Compare
…and hermetic test suite (fixes BasedHardware#13978)
d3819b7 to
66c5264
Compare
Dismissed: the blocking concern in this review (JATS/HTML tag stripping dropped from clean()) is resolved on the current head — _JATS_TAG/_CLOSE_TAG/_OPEN_TAG restored alongside whitespace normalization, with regression tests test_clean_jats_and_html_tag_stripping and test_get_work_jats_abstract_rendered_cleanly (suite 8/8 green).
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @arawnslab-hash — the blocking JATS/HTML stripping concern from my earlier review is resolved on this head: _JATS_TAG/_CLOSE_TAG/_OPEN_TAG are restored in clean() alongside your whitespace normalization, and test_clean_jats_and_html_tag_stripping + test_get_work_jats_abstract_rendered_cleanly lock it in. I ran the suite locally: 8/8 pass, fully hermetic. The crossref-app-tests registration in .github/checks-manifest.yaml is also correctly placed with both local and ci lanes.
One new blocking regression, introduced when the branch history was rewritten (the previously reviewed head still had these): this head deletes GET /tools and GET /.well-known/omi-tools.json from plugins/omi-crossref-app/main.py. Both endpoints exist on main today. /.well-known/omi-tools.json is the documented chat-tools discovery contract — Omi's backend fetches it via fetch_app_chat_tools_from_manifest (backend/utils/apps.py) when registering an app's tools, and every sibling plugin app (omi-pubmed-app, omi-open-meteo-app, omi-frankfurter-app, …) exposes it. Removing it means Omi can no longer discover this app's three tools from the deployed instance. The PR description doesn't mention this removal. Please restore both endpoints — everything else in the refactor can stay as is.
Non-blocking:
search_crossref_worksdrops the explicitsort=relevance, order=descparams that main sends. Crossref defaults to score ordering for queried/works, so this is likely a no-op in practice — but it's an undeclared behavior change; either keep the params or add a one-line note.- Query validation was relaxed from "at least 2 characters" to non-empty for search, while author search still requires >=2. One-character queries now reach the API. Fine if intentional; flagging the asymmetry.
- Every test patches
crossref_get, so the pooling /is_closedfallback branch — the headline change — still has no direct coverage. A small test drivingcrossref_getwith a mocked client for both the pooled and fallback paths would close that (this is whyneeds-testsstays for now). - The
crossref-app-teststrigger list omits.github/checks-manifest.yaml(the frankfurter entry includes it). Minor consistency point; either convention is defensible.
The null/non-dict payload guards and the lifespan-managed client remain solid. Once the two discovery endpoints are restored, I have no further code concerns on this head.
by AI on behalf of David
|
Hey @arawnslab-hash 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
What changed and why
In
plugins/omi-crossref-app/main.py:httpx.AsyncClientinstantiation with connection pooling via FastAPIlifespanhandler (app.state.client), preventing socket churn and connection exhaustion under load while retaining client lifecycle fallback.search_crossref_works,get_crossref_work, andget_crossref_works_by_authorto preventAttributeErrorwhen Crossref returns{"message": null}or non-dict error payloads.plugins/omi-crossref-app/test_crossref.py.Product invariants affected
none
How it was verified
Executed full hermetic test suite across
test_crossref.py. All 5 tests pass cleanly with 0 external network dependencies:Tests
plugins/omi-crossref-app/test_crossref.py:test_search_works_null_message_payloadtest_search_works_non_dict_payloadtest_get_work_null_message_payloadtest_get_works_by_author_null_message_payloadtest_search_works_successFailure class (fixes)
Failure-Class: none
Bounty Payout Details
[email protected]0xa709768e0B597df11b2B81AB7ea54EEacd2532D0