Repository navigation
Conversation
|
Verified end to end against #13978 — this is a solid hardening pass. Per-file notes:
Leaving the formal review/merge call to a human maintainer; from a code-correctness standpoint everything here checks out. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
1066f14 to
1fa7bba
Compare
|
@kodjima33 Rebased onto latest main! Clean and mergeable. |
|
Follow-up after the rebase onto latest main (head now 1fa7bba):
The two nits from the earlier automated pass ( by AI on behalf of David |
aryanorastar
left a comment
There was a problem hiding this comment.
Verified on 1fa7bbaa7e4c.
Crossref guards null/non-dict payloads and pools the HTTP client. I ran plugins/omi-crossref-app/test_main.py against this tip: 31/31 OK.
kodjima APPROVE is not a merge. I am not merging.
|
Crossref on main still opens a new HTTP client per request. This head adds pooling and null guards, and its checks are green, but the diff is against the pre-DOI — Astar, on behalf of @aryanorastar |
## What changed and why Follow-up to #14523. The resolver normalization from #14606 correctly parses trusted `doi.org` URLs, but its DOI suffix grammar rejects registered identifiers containing reserved characters such as `<` and `>`, as well as encoded suffix characters such as `&`, `?`, `=`, `@`, `+`, and `%`. This rebased change keeps the hardened scheme, host, credential, port, and decode-once checks already on `main`, while accepting visible Unicode DOI suffix characters and legacy dotted registrant codes. It rejects whitespace, controls, format code points, unassigned characters, and non-ASCII prefix digits. The normalized DOI is still quoted with `safe=""`, so reserved characters and traversal-like suffix text remain inside one Crossref API path segment. This is complementary to #13979: that PR handles malformed Crossref response payloads and HTTP client pooling, while this PR covers DOI input compatibility at the request boundary. ## Product invariants affected none ## How it was verified - `python plugins/omi-crossref-app/test_doi_normalization.py` — 26 passed. - `python -m pytest plugins/omi-crossref-app -q --tb=short` — 33 passed. - `python -m compileall -q plugins/omi-crossref-app` — passed. - `git diff --check` — no whitespace errors. - Live Crossref lookup of registered DOI `10.1002/1097-4636(200108)56:2<297::aid-jbm1098>3.0.co;2-s` returned HTTP 200 and the expected work when the DOI was quoted as one path segment. The full manifest preflight cannot resolve in this sparse checkout because unrelated manifest paths under backend, mobile, web, and desktop are absent. The selected hermetic Crossref command and the complete plugin suite pass directly. ## Tests `plugins/omi-crossref-app/test_doi_normalization.py` now covers encoded reserved suffix characters, exact-once decoding with a remaining literal percent escape, legacy dotted registrant codes, a real registered DOI containing angle brackets, visible Unicode suffixes, rejected control/format/unassigned code points, rejected non-ASCII prefix digits, repeated-dot suffixes, and the exact outbound quoted Crossref path. ## Backend Hermetic Merge Gate Out of scope: this change only touches the Crossref plugin and its existing hermetic DOI suite; it does not change backend, lockfile, workflow, or gate paths. ## Failure class (fixes) Failure-Class: FC-overstrict-identifier-grammar ## New guards No new check is added. The existing `crossref-doi-normalization-tests` manifest entry runs the extended behavioral suite and would catch the over-restrictive DOI grammar. The research, implementation, and tests were prepared with Codex assistance on behalf of @dvdphobia.
e4c31ef to
d7d0494
Compare
|
@aryanorastar Rebased cleanly on latest |
aryanorastar
left a comment
There was a problem hiding this comment.
Reviewed d7d0494.
Crossref on main still opens a new httpx.AsyncClient per request. This head pools the client, guards null and non-dict payloads, and adds _extract_title. _is_valid_doi and normalize_doi stay. The manifest entry is a complete omi-crossref-tests block. Hygiene is green on this head.
Not merging. The previous approval was on 1fa7bba. Mobile and Desktop Swift checks are still running and do not touch this plugin. #14588 stays open.
|
Keeping this open on d7d0494. Crossref search on main still indexes title[0] and walks message.items with no isinstance guard. This head adds those guards and a pooled client. Not one defect. Not merging. Not merging. — Astar, on behalf of @aryanorastar |
|
Verified this end to end: diffed the head against current main (cleanly rebased; the DOI-normalization and face-markup work already on main is untouched), and ran the new suite locally with Per file:
Two non-blocking notes: (1) the pooling path itself ( Thanks @shitobu — this is a genuinely useful hardening of the Crossref plugin, and it's already maintainer-approved on this head. Leaving the two notes above for the merge decision. Feedback generated by an AI reviewer operating as a maintainer assistant on David's behalf. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
aryanorastar
left a comment
There was a problem hiding this comment.
d7d0494226cc — plugins/omi-crossref-app/main.py still returns Crossref request failed: {exc} next to the new isinstance guards. That return has to go.
|
Updated in commit • Removed the raw |
|
Verified on 371d2fa — the raw File-by-file:
One tradeoff to keep on record: since exceptions now collapse into "No Crossref results found", a transient timeout or DNS failure looks identical to a genuine empty result. That is the requested behavior, but it means connectivity issues will be silent — worth remembering if the tool ever looks like it returns nothing under load. The prior changes-requested review was against an older commit, so leaving this for a human maintainer to re-acknowledge on the new head before merge. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
@shitobu this conflicts with |
…ds, and register hermetic test suite
371d2fa to
4769d14
Compare
|
Rebased cleanly onto latest |
aryanorastar
left a comment
There was a problem hiding this comment.
On 4769d14c2a6d99e2ffdd746a65e1b4b99d955d5b, plugins/omi-crossref-app/main.py turns transport failures and non-dict payloads into an empty No Crossref result and drops the 404 branch. Keep _REQUEST_FAILED_MESSAGE and the 404 path.
Git-on-my-level
left a comment
There was a problem hiding this comment.
One fix needed before merge: the pooling and payload guards are solid, but this head collapses Crossref failures into empty-success responses — which is exactly what the failing Hygiene guard suite catches.
What's working well:
plugins/omi-crossref-app/main.py— the lifespan-managedhttpx.AsyncClientwith a lazy_get_crossref_client()fallback (including theis_closedre-open check) removes the per-request connection churn that current main still has, and the User-Agent header with a contact mailto follows Crossref's API etiquette._extract_title()and the hardenedextract_year()(isinstance checks through the date-parts nesting) are the right guards for malformed records, andclamp_max_results()now survives junk input instead of raising.plugins/omi-crossref-app/test_main.py— 31 hermetic tests with scopedsys.modulespatching; null/non-dict payloads covered for all three tools; runs on stdlib alone..github/checks-manifest.yaml— theomi-crossref-testsentry mirrors the neighboring blocks (command, triggers including the manifest itself, lanes).
Blocking issue (verified on 4769d14):
- All three handlers —
search_crossref_works,get_crossref_work,get_crossref_works_by_author— now setdata = Noneinsideexceptand returnresult="No Crossref … found"instead oferror=_REQUEST_FAILED_MESSAGE._REQUEST_FAILED_MESSAGEis defined (main.py:48) but never used on this head, so a Crossref outage or timeout is indistinguishable from an empty search. get_crossref_workdrops thehttpx.HTTPStatusError404 branch, so a genuine 404 reports as a bare "No Crossref details found" result instead of "No Crossref record found for DOI …".- This is precisely why Hygiene is red: main's guard suite
plugins/omi-crossref-app/test_doi_normalization.py(ErrorSanitizationTests, from #14523) runs against this PR's tree and fails 4/30 —test_get_work_404_reports_not_found_without_leaking_exceptionandtest_get_work_server_error_is_sanitizedfail on the removed error channel, and the search/author transport-failure sanitization tests fail the same way. This branch predates that suite, so it needs a merge/rebase from main regardless.
How to resolve:
- Keep the new isinstance guards for malformed-but-200 payloads, but restore the error channel: on exception return
error=_REQUEST_FAILED_MESSAGE(log the exception type only, as you already do), and restore the 404 branch inget_crossref_work. The two behaviors are fully compatible. - After merging main, update the three exception-path tests in
test_main.py(test_search_works_exception_handled,test_get_work_exception_handled,test_get_works_by_author_exception_handled) to assert the error contract rather than the empty-result string, so both suites agree.
Security: clean — error paths stay sanitized (exception type in logs only), no new dependencies, no secrets surfaced.
USER IMPACT: as-is, a Crossref outage would tell users "No Crossref results found" instead of a retryable error — downtime would look like empty data.
Leaving in human maintainer review alongside the open change request, which pins this exact error-channel contract; happy to re-review once the guard suite is green.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Thanks for this contribution! Our review requested some changes (see above) and we haven't heard back in a while. If you're still working on it, just push a commit or leave a comment within the next 7 days. To keep the queue healthy we'll close this PR in 14 days if it stays inactive — and it can always be reopened once updates land. Happy to re-review! |
|
Hey @shitobu 👋 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
Fixes #13978.
This PR hardens
plugins/omi-crossref-appagainst connection churn, socket exhaustion, and unhandled runtime exceptions:httpx.AsyncClientwith fallback, avoiding per-request connection churn.messageanditemsacrosssearch_crossref_works,get_crossref_work, andget_crossref_works_by_authoragainst null/non-dict API responses._extract_titleand hardensextract_yearagainst malformed or empty date/title structures.plugins/omi-crossref-app/test_main.pycontaining 31 tests covering route wiring, endpoints, and error paths, running in 0.25s under stdlibunittestwith scoped module isolation.omi-crossref-testsin.github/checks-manifest.yaml.Product invariants affected
none
How it was verified
python3 -S plugins/omi-crossref-app/test_main.py(31 tests pass in 0.25s with no external dependencies).pytest plugins/omi-crossref-app/test_main.py(31 passed in 0.89s).git diff --check upstream/main(0 formatting/whitespace errors).Tests
plugins/omi-crossref-app/test_main.py:RouteWiringTests: Endpoint paths, HTTP methods, response models, and tools manifest contracts.CleanTextTests: JATS paragraph stripping, HTML entity unescaping, inequality operator preservation.ExtractionHelperTests: Date parts published-print/online/issued fallbacks, malformed date lists, and title extraction.CrossrefToolTests:test_search_works_successtest_search_works_empty_itemstest_search_works_null_message_gracefultest_search_works_non_dict_payload_gracefultest_search_works_short_query_errortest_search_works_exception_handledtest_get_work_successtest_get_work_invalid_doi_formattest_get_work_directory_traversal_doitest_get_work_null_message_gracefultest_get_work_empty_message_gracefultest_get_work_non_dict_payload_gracefultest_get_works_by_author_successtest_get_works_by_author_empty_resultstest_get_works_by_author_null_message_gracefultest_get_works_by_author_non_dict_payload_gracefultest_get_works_by_author_short_name_errorFailure class (fixes)
Failure-Class: none
New guards (only when adding a check or ratchet)
Adds
omi-crossref-teststo.github/checks-manifest.yaml.