omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(edit-tools): guard None/invalid inputs and harden owner resolution in edit tools ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 2 comments

Summary

In backend/utils/retrieval/tools/edit_tools.py, several input coercions, None guards, and owner UID resolution edge cases lead to unhandled runtime exceptions (AttributeError, TypeError, or crashes during LangChain invocations):

  1. owner(config) crash when configurable is None:
    • When callers or LangChain runners pass a config where configurable is explicitly None (e.g. {'configurable': None}), config.get('configurable', {}).get('user_id') raises AttributeError: 'NoneType' object has no attribute 'get'.
    • owner(config) only inspected config.get('configurable', {}).get('user_id'), ignoring top-level keys like config['user_id'] or config['uid'] used in direct tool calls and testing harness configurations.
  2. Unvalidated inputs in update_conversation, rename_person, edit_memory, and delete_memory:
    • If LLMs pass correction=None or empty whitespace to update_conversation, calling .strip() raises AttributeError: 'NoneType' object has no attribute 'strip'.
    • In rename_person, passing non-string or empty new_name raises AttributeError: 'NoneType' object has no attribute 'strip' rather than returning a structured tool error.
    • In edit_memory, passing None or non-string new_text raises AttributeError: 'NoneType' object has no attribute 'strip'.
    • In delete_memory, passing None or empty memory_id raises unhandled exceptions rather than early domain validation.
  3. Missing default None for config: RunnableConfig parameter:
    • Tool methods declared *, config: RunnableConfig as a required keyword argument without default = None. Direct tool invocations or direct testing without config raised TypeError: missing 1 required keyword-only argument: 'config'.

Proposed Changes

  1. Resilient owner(config) Resolution & _get_configurable Helper: Safely extract user ID checking configurable.get('user_id') or config.get('user_id') or config.get('uid'), handling None or non-dict configurable gracefully.
  2. Safe Input Guards Across All Edit Tools: Validate non-empty strings for correction, new_name, new_text, and memory_id, returning informative tool_error messages (invalid_correction, invalid_name, invalid_text, invalid_memory_id) instead of crashing.
  3. Optional config: RunnableConfig = None: Allow direct tool invocations with default config = None.
  4. Hermetic Unit Tests: Add backend/tests/unit/test_edit_tools_guards.py verifying owner resolution, None guards, empty strings, character limits, and config resilience (8 tests, 100% pass).

Bounty Proposal

Proposed bounty: $50 USDC Payout address: 0xC345C07229307d4f1c7935aD2cAe48e390215808 (USDC Polygon/Base/Arbitrum)

Dimank92 avatar Oct 22 '26 05:10 Dimank92

I have implemented the complete fix and hermetic unit tests in PR #23240.

  • Pull Request: https://github.com/BasedHardware/omi/pull/23240
  • Unit Tests: 8/8 passing hermetically
  • Payout Address: 0xC345C07229307d4f1c7935aD2cAe48e390215808 (USDC Polygon/Base/Arbitrum)

Dimank92 avatar Oct 22 '26 05:10 Dimank92

Thanks for putting this together. We aren't doing bounties at the moment, so we're closing the bounty proposal issues for now — thanks for the fix! 🙏

undivisible avatar Oct 22 '26 12:10 undivisible