omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(action-item-tools): resolve top-level user_id, coerce limit/offset, and guard None configurable ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 3 comments

Summary

In backend/utils/retrieval/tools/action_item_tools.py, get_action_items_tool, create_action_item_tool, and update_action_item_tool manage user tasks and to-do items.

Runtime Crashes & Vulnerabilities

  1. Broken user_id resolution for top-level configurations and None configurable:

    • In get_action_items_tool:
      if 'configurable' not in cfg:
          return "Error: Configuration format invalid"
      configurable: Any = cfg.get('configurable')
      uid = configurable.get('user_id')
      
      When config is a dictionary with top-level user_id (e.g. {"user_id": "test_uid"}), 'configurable' not in cfg returns an error. When configurable is present but None ({'configurable': None}), calling .get('user_id') crashes with AttributeError: 'NoneType' object has no attribute 'get'.
    • In create_action_item_tool and update_action_item_tool:
      configurable: Any = cfg.get('configurable')
      uid = configurable.get('user_id')
      
      When configurable is None, .get('user_id') crashes with AttributeError, aborting execution.
  2. Fatal TypeError: '>' not supported between instances of 'str' and 'int' on string limit: In get_action_items_tool(limit: int = 50, offset: int = 0, ...): When an LLM agent provides arguments with string numbers (e.g. limit="50" or offset="0"):

    if limit > 500:
    

    In Python 3, evaluating str > int immediately raises TypeError: '>' not supported between instances of 'str' and 'int', crashing the tool invocation.

  3. Missing input sanitization on description and action_item_id:

    • In create_action_item_tool, description.strip() crashes with AttributeError if description is None.
    • In update_action_item_tool, passing empty action_item_id causes downstream query failure without immediate validation.

Fix

  • Introduced _extract_user_context(cfg) helper extracting user_id from either nested configurable or top-level cfg, safely defaulting configurable to {}.
  • Defensively coerced and clamped limit to [1, 500] and offset to >= 0, preventing TypeError.
  • Normalized and validated non-empty description and action_item_id.
  • Added comprehensive hermetic unit tests in backend/tests/unit/test_action_item_tools.py.

Bounty Proposal

  • Proposed tier: $50 (Targeted bug fix + unit test coverage)
  • Settlement: Base Mainnet USDC / Stripe / Singapore Card

Dimank92 avatar Oct 21 '26 20:10 Dimank92

Resolved in PR #23110. Added _extract_user_context helper for robust user_id resolution, limit/offset integer coercion, input validation, and full unit test suite in backend/tests/unit/test_action_item_tools.py.

Dimank92 avatar Oct 21 '26 20:10 Dimank92

Fix submitted via #23118 with comprehensive unit tests (9/9 passing).

  • Safely resolves top-level and nested user_id with None configurable guards.
  • Coerces and clamps limit [1, 500] and offset >= 0, preventing TypeError.
  • Validates required description and action_item_id.

Payout address (Base USDC): 0xb95e2AD8E9D9e9BF902c7531577Cd0E1ceB203D4

Booshdag-io avatar Oct 21 '26 20:10 Booshdag-io

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 11:10 undivisible