Repository navigation
fix(crossref): add typed request models, guard against non-dict payloads, add lifespan client, and 20 hermetic tests - #13985
Conversation
|
Verified end-to-end — this is a solid, well-scoped hardening pass. Thank you! What I checked:
Two small non-blocking notes:
Leaving merge sign-off to a human maintainer: this is a first-time contribution that extends the chat-tool error contract (422→200 envelope) and adds a CI check lane, both worth a maintainer's eyes before merge. No security concerns found — the payload guards are purely defensive parsing of upstream Crossref responses; no auth, secrets, or user-data surfaces touched. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Adds typed Pydantic request models, guards non-dict/null Crossref payloads, adds lifespan-pooled httpx client with fallback, and 20 hermetic tests registered in checks-manifest.yaml. httpx already a declared dependency (no missing-dep issue). Closes #13983. Confidence 5/5 (test-heavy diff, root cause, CI, real bug).
…ads, add lifespan client, and 20 hermetic tests (BasedHardware#13983)
7eda468 to
ab7f29d
Compare
|
Note for maintainers / bounty payout: Please ensure all bounty rewards for this PR are routed to my verified EVM / Base wallet: 0xb5aFc89b57Fa8270bB7261348179D28099BEa2a0. Thank you! |
|
Payout information update:
Thank you! |
|
Follow-up verification on the rebased head ( Content unchanged since approval. All four files in this PR are byte-identical (matching blob SHAs) to the commit @kodjima33 approved, so that approval still covers this content — the only manifest delta is main-side entries picked up by the rebase (open-meteo, github-app, semantic-scholar test entries). Re-verified per file:
One contributor action needed to unblock CI — PR Metadata Preflight. The commit subject starts with The Desktop Swift failures are not from this PR. "Desktop Swift Build & Tests" and "Desktop Swift Static & Test Contracts" fail identically on current This feedback is AI-generated on behalf of David (@Git-on-my-level). by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Keeping this open. Not approving — Astar, on behalf of @aryanorastar |
|
Closing as a later copy of #13979. The earlier pull request is the one to keep. |
|
Hey @Ivansky1 👋 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! |
Summary of Changes
Fixes #13983
This PR addresses several critical reliability, error handling, input validation, and architectural issues in
plugins/omi-crossref-app:Typed Request Validation Models & Chat-Tool Error Envelope:
SearchCrossrefRequest: validates non-empty query string and clampsmax_results(1-10, default 5).GetCrossrefWorkRequest: validates DOI formatting (requires slash, disallows path traversal..), trims whitespace.GetCrossrefAuthorWorksRequest: validates non-empty author query and clampsmax_results(1-10, default 5).@app.exception_handler(RequestValidationError)returning HTTP 200 with standardChatToolResponse(error="invalid tool request: ...")envelope matching the chat-tool contract.ChatToolResponsewith model validator ensuring exactly one ofresultorerroris populated.Defensive Nested Payload Parsing:
_extract_title: safely handles when title is a list of strings (["Title"]), a single scalar string ("Title"), or None, preventing character slicing bugs ("Machine Learning"[0]->"M").extract_year: defensively validatesdate-partsstructure against non-dict or non-list entries and missing indices, preventingTypeErrorandIndexError.clean(): safely preserves JATS tag stripping and HTML unescaping while handlingNonecleanly without failing.search_crossref_works,get_crossref_work, andget_crossref_works_by_author: defensively check that response payloads and nested items are valid dictionaries, returning clean error messages instead of raising uncaught exceptions.HTTP Client Lifecycle & Connection Pooling:
lifespancontext manager managing a persistent pooledhttpx.AsyncClientonapp.state.http_client.Hermetic Test Suite & Checks-Manifest Registration:
plugins/omi-crossref-app/test_main.pycontaining 20 hermetic unit tests verifying all endpoints, helpers, defensive extraction edge cases, and lifespan fallback with zero external network dependencies.load_app_modules(force_stubs=True).crossref-testsin.github/checks-manifest.yamlwith#13983:traceability prefix.Bounty & Payout Information
0xb5aFc89b57Fa8270bB7261348179D28099BEa2a0