Repository navigation
fix(perplexity-tools): sanitize unexpected search exception handling - #15632
gewenbo888 wants to merge 2 commits into
Conversation
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @gewenbo888 — the production change here is a real improvement and verified minimal.
What's good (verified on head 29d357d):
- backend/utils/retrieval/tools/perplexity_tools.py (+6/-2): the generic except now returns a fixed user-facing string instead of interpolating str(e), and the log line uses lazy %-formatting with type(e).name + exc_info rather than embedding the exception text. The other error paths in this file were already sanitized (sanitize() on response slices, fixed strings), so this closes the last raw leak to chat-tool callers.
- backend/tests/unit/test_perplexity_tools_sanitization.py: both tests pass when executed directly (2/2, exit 0), and the first pins the exact new sanitized return string.
- .github/checks-manifest.yaml: registering the test as a diff-scoped check with local+ci lanes follows the existing entries (e.g. the test_verify_pusher_* unit checks).
One blocking item — missing Failure-Class declaration:
- The commit subject starts with fix:, so the repo's failure-class-protocol gate (it runs on every PR) requires exactly one of these lines in the PR body: Failure-Class: FC-, Failure-Class: new, or Failure-Class: none. Running the gate's own command locally against this PR's body and commit fails with: "a commit subject beginning with fix: requires a Failure-Class declaration in the PR body". Run python3 scripts/pr-preflight --suggest for the matching class citation, then add the line to the PR description. (The "Verified 29/29 manifest checks passing" note in the description can't have included this gate — worth re-running make preflight after the edit.)
Non-blocking, but please consider:
- The test installs sys.modules fakes at import time via the module-scope _pkg/_mod/_load helper calls. That's exactly the pattern backend/docs/test_isolation.md and backend/scripts/check_module_stub_pollution.py exist to retire — the static checker passes only because the writes live inside helper functions, and today's per-file pytest isolation is what hides it. The sanctioned replacement is backend/testing/import_isolation.py (AutoMockModule, or stub_modules inside a fixture). Not blocking since the runner still isolates per file, but new tests shouldn't add to that migration debt.
Happy to re-review once the declaration is added — the code change itself looks ready.
🤖 Automated review on behalf of the maintainers.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
|
Added |
|
Perplexity search on main still returns — Astar, on behalf of @aryanorastar |
|
Keeping this open. Not approving — Astar, on behalf of @aryanorastar |
29d357d to
659cf4a
Compare
|
Updated on head
Ready for CI checks and re-review. Thanks! |
|
@Git-on-my-level: The Failure-Class declaration ( |
|
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! |
Dismissed as resolved: the PR body now declares 'Failure-Class: none', which satisfies the failure-class-protocol gate that was the single blocking item in this review. The production change is unchanged and verified on the current head.
|
Thanks @gewenbo888 — following up on the earlier automated review of head 29d357d. The one blocking item is resolved: the PR body now declares Verified on the current head 659cf4a:
Non-blocking, unchanged from before: the module-scope This closes the review loop from my side — the code change looks ready for maintainer merge. Also dropping 🤖 Automated review on behalf of the maintainers. by AI on behalf of David. |
|
@gewenbo888 this conflicts with |
|
Closing. This is already on main via #19406. Not merged. |
|
Hey @gewenbo888 👋 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
Sanitize unexpected exception handling and error returns in
_perplexity_gateway_search(backend/utils/retrieval/tools/perplexity_tools.py).Changes
"Error: An unexpected error occurred while searching. Please try again later."without leaking raw{str(e)}.logger.error("❌ perplexity_web_search_tool - Unexpected error: %s", type(e).__name__, exc_info=True)instead of interpolating{e}directly into log string.backend/tests/unit/test_perplexity_tools_sanitization.pyverifying sanitization across unexpected exceptions and response format parsing..github/checks-manifest.yaml.origin/main.Failure-Class: none