omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(screen-activity): validate query, coerce limit, and guard app_filter matching ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 2 comments

Summary

In ackend/utils/retrieval/tools/screen_activity_tools.py:

  1. search_screen_activity_tool does not validate query, causing query=None or empty/whitespace strings to trigger unhandled AttributeError: 'NoneType' object has no attribute 'casefold' in keyword fallback and API errors in gemini_embed_query(query).
  2. String or invalid limit arguments (e.g. limit="10" or limit=None) trigger TypeError: '<' not supported between instances of 'int' and 'str' in min(limit, 20).
  3. In get_screen_activity_tool, pp_filter case matching ame.lower() == app_filter.lower() does not strip surrounding whitespace and raises AttributeError if ame is None in observation dictionaries.
  4. Top-level user_id resolution fallback is missing when configurable is omitted in config.
  5. There are no unit tests for screen_activity_tools.py in ackend/tests/unit.

Proposed Changes

  1. Query Validation: Validate clean_query = str(query or '').strip() early in search_screen_activity_tool. Return Error: Search query cannot be empty. when query is blank or None.
  2. Limit Coercion: Safely coerce limit to integer with bounds clamping max(1, min(clean_limit, 20)).
  3. App Filter Sanitization: Strip and safely lower-case pp_filter and ame strings to prevent case/whitespace mismatches and NoneType errors.
  4. Resilient User Context Resolution: Support fallback to top-level cfg.get('user_id') in _get_uid.
  5. Hermetic Unit Tests: Add ackend/tests/unit/test_screen_activity_tools.py verifying query validation, limit coercion, app filter matching, config user_id resolution, and keyword fallback error handling.

Bounty: $50 proposed.

Dimank92 avatar Oct 21 '26 20:10 Dimank92

PR created with hermetic unit tests: https://github.com/BasedHardware/omi/pull/23128

Dimank92 avatar Oct 21 '26 20: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