Repository navigation
fix(retrieval): sanitize raw system exceptions in action item tools - #19680
xyz-is-best wants to merge 3 commits into
Conversation
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks @xyz-is-best — the core change here is verified correct, and it closes a real leak: until now the three action-item tools returned f-strings built from raw exception text straight to the agent. Details below, plus three items that need another push before this can merge.
What's good (verified against current main):
- backend/utils/retrieval/tools/action_item_tools.py: all three handlers (get_action_items_tool, create_action_item_tool, update_action_item_tool) now log the exception through utils.log_sanitizer.sanitize() and return a fixed fallback message instead of "Error ...: {str(e)}". This matches the established sanitization pattern already on main for the file and calendar tools. Dropping the traceback.print_exc() call also removes raw stack traces from stdout. The import is valid — backend/utils/log_sanitizer.py exists on current main and your branch is up to date with it.
- backend/tests/unit/test_action_item_tools_sanitization.py: all three new tests ran and passed (3/3) in this head's CI run, asserting the Firestore document path never reaches the tool result and that an ERROR log is still emitted.
What needs fixing before merge:
- Formatting check fails: the pinned black would reformat backend/tests/unit/test_action_item_tools_sanitization.py (e.g. the multi-line
assert (res == \"...\")blocks fit on one line). Please run the repo's black over the file. - Hygiene check fails: the PR body is missing the required
Failure-Class: FC-<lower-kebab-slug>declaration (failure-class-protocol). Please add it to the description. - Backend unit shards 1/3 fail — this is a test-isolation artifact rather than a defect in your production change, but it does need a fix in this PR. tests/unit/test_action_item_date_validation.py, tests/unit/test_action_items_timezone.py and tests/unit/test_action_item_tool_result_bound.py load action_item_tools.py through _load_module_from_file after replacing the whole utils package with an empty stub (_stub_package("utils") with path=[]). The new
from utils.log_sanitizer import sanitizeimport therefore fails at collection with ModuleNotFoundError: No module named 'utils.log_sanitizer'. Fix: add "utils.log_sanitizer" to those files' stubbed-module lists with a passthrough sanitize (e.g. a stub whose sanitize is str), the same way utils.conversations.render is stubbed.
One non-blocking observation: sanitize() only masks token-like strings that contain digits/base64 characters, plus emails — pure-alpha identifiers pass through. So for an error like "Firestore connection failed: /databases/default/documents/users//action_items" with an all-alpha uid, the masked log line still contains the full document path. The tool response no longer leaks it (the important part); you may want to pin that log-side behavior in a test or note it as best-effort.
Requesting changes for items 1–3; happy to re-review after the push. The production-code path itself was verified correct against current main.
Automated maintainer-review feedback on behalf of the Omi 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.
…test with black 26.5.1
|
Closing as a later copy of #19661. The earlier pull request is the one to keep. |
|
Hey @xyz-is-best 👋 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
Sanitizes unhandled database and serialization exceptions across action item retrieval and mutation tools under
backend/utils/retrieval/tools/action_item_tools.py.Problem Statement
Action item retrieval tools did not uniformly sanitize unexpected database connection dropped events or malformed entity attributes, leading to unhandled 500-level tracebacks surfaced to client interfaces.
Solution & Changes
Verification
Failure-Class: FC-exception-leak