omi
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)
Problem & Root Cause Analysis
In backend/utils/retrieval/tools/app_tools.py:
-
AttributeError & TypeError on Permissive JSON Schemas in
_create_pydantic_model_from_schema:- When an app manifest supplies
"properties": Noneor"required": None,parameters.get('properties', {})returnsNone, causingfor param_name, param_schema in properties.items()to crash withAttributeError: 'NoneType' object has no attribute 'items'. set(parameters.get('required', []))crashes withTypeError: 'NoneType' object is not iterableif"required": None.- If an individual property schema has
Nonedefinition (e.g.{"properties": {"query": None}}),param_schema.get('type')raisesAttributeError.
- When an app manifest supplies
-
Identifier & Model Name Syntax Errors:
model_name = f"{tool_name.replace('-', '_').replace('.', '_')}Input"crashes or raisesValueErrorin dynamic Pydantic model creation iftool_namestarts with digits or contains non-alphanumeric characters (colons, slashes, spaces).
-
Missing Top-Level
user_idFallback in_call_tool_endpoint:_call_tool_endpointonly looked upuser_idinsideconfig.get('configurable'). When callers passconfig['user_id']at the top level, or whenconfigurableis omitted/None,uidremainedNoneand failed with"Error: User ID not found".
-
AttributeError on Null
method& Missingendpointin_call_tool_endpoint:method = app_tool.method.upper()crashes withAttributeError: 'NoneType' object has no attribute 'upper'when an app tool definition hasmethod: None.- If
app_tool.endpointis empty or missing,get_webhook_circuit_breakerreceives an empty target and httpx fails unhandled.
-
TypeError on None
get_enabled_appsandchat_toolsinload_app_tools:for app_id in enabled_app_ids:raisesTypeError: 'NoneType' object is not iterableif Redis/DB helper returnsNone.- Iterating over
app.chat_toolswithout checking forNoneitems causesapp_tool.nameto crash if a corrupted or partial list is stored.
-
MCP Transport Default:
- Guaranteed safe fallback to
'sse'whenapp_tool.transportis unset.
- Guaranteed safe fallback to
Solution
- Added
_clean_identifierhelper to safely normalize arbitrary tool names and parameter keys into valid Python identifiers. - Hardened
_create_pydantic_model_from_schemaagainstNoneproperties,Nonerequired lists, andNoneparameter schemas. - Added fallback
uid = configurable.get('user_id') or config.get('user_id')in_call_tool_endpoint. - Guarded
app_tool.methodto default to'POST', and validatedapp_tool.endpoint. - Guarded
get_enabled_apps(uid) or []and sanitized items inchat_tools. - 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
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
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! 🙏