omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(app-tools): guard null properties in parameter schemas, fallback user_id, and sanitize tool names and methods ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 2 comments

Problem & Root Cause Analysis

In backend/utils/retrieval/tools/app_tools.py:

  1. AttributeError & TypeError on Permissive JSON Schemas in _create_pydantic_model_from_schema:

    • When an app manifest supplies "properties": None or "required": None, parameters.get('properties', {}) returns None, causing for param_name, param_schema in properties.items() to crash with AttributeError: 'NoneType' object has no attribute 'items'.
    • set(parameters.get('required', [])) crashes with TypeError: 'NoneType' object is not iterable if "required": None.
    • If an individual property schema has None definition (e.g. {"properties": {"query": None}}), param_schema.get('type') raises AttributeError.
  2. Identifier & Model Name Syntax Errors:

    • model_name = f"{tool_name.replace('-', '_').replace('.', '_')}Input" crashes or raises ValueError in dynamic Pydantic model creation if tool_name starts with digits or contains non-alphanumeric characters (colons, slashes, spaces).
  3. Missing Top-Level user_id Fallback in _call_tool_endpoint:

    • _call_tool_endpoint only looked up user_id inside config.get('configurable'). When callers pass config['user_id'] at the top level, or when configurable is omitted/None, uid remained None and failed with "Error: User ID not found".
  4. AttributeError on Null method & Missing endpoint in _call_tool_endpoint:

    • method = app_tool.method.upper() crashes with AttributeError: 'NoneType' object has no attribute 'upper' when an app tool definition has method: None.
    • If app_tool.endpoint is empty or missing, get_webhook_circuit_breaker receives an empty target and httpx fails unhandled.
  5. TypeError on None get_enabled_apps and chat_tools in load_app_tools:

    • for app_id in enabled_app_ids: raises TypeError: 'NoneType' object is not iterable if Redis/DB helper returns None.
    • Iterating over app.chat_tools without checking for None items causes app_tool.name to crash if a corrupted or partial list is stored.
  6. MCP Transport Default:

    • Guaranteed safe fallback to 'sse' when app_tool.transport is unset.

Solution

  1. Added _clean_identifier helper to safely normalize arbitrary tool names and parameter keys into valid Python identifiers.
  2. Hardened _create_pydantic_model_from_schema against None properties, None required lists, and None parameter schemas.
  3. Added fallback uid = configurable.get('user_id') or config.get('user_id') in _call_tool_endpoint.
  4. Guarded app_tool.method to default to 'POST', and validated app_tool.endpoint.
  5. Guarded get_enabled_apps(uid) or [] and sanitized items in chat_tools.
  6. Added 10 hermetic unit tests in backend/tests/unit/test_app_tools_schema_and_guards.py (100% passing).

Payout Details

  • Proposed Bounty: $50
  • USDC (Polygon / Base / Arbitrum): 0xC345C07229307d4f1c7935aD2cAe48e390215808

Dimank92 avatar Oct 22 '26 04:10 Dimank92

Fix implemented and covered by 10 hermetic unit tests in PR #23197.

Bounty Proposal & Claim

  • Target Issue: #23196 ($50 proposed)
  • PR: https://github.com/BasedHardware/omi/pull/23197
  • USDC (Polygon / Base / Arbitrum): 0xC345C07229307d4f1c7935aD2cAe48e390215808

Dimank92 avatar Oct 22 '26 04: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 11:10 undivisible