omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(calendar-tools): guard untitled event summary matching, coerce max_results, and validate time ranges ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 2 comments

Summary

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

  1. AttributeError on untitled events (summary: None): In delete_calendar_event_tool and update_calendar_event_tool, event matching by title does:
    matching_events = [e for e in events if event_title.lower() in e.get('summary', '').lower()]
    
    When a calendar event has 'summary': None (standard in Google Calendar for untitled events, ICS imports, or external integrations), e.get('summary', '') returns None rather than ''. The subsequent .lower() call raises AttributeError: 'NoneType' object has no attribute 'lower', terminating tool execution with an unhandled exception.
  2. TypeError on string max_results in get_calendar_events_tool: LLMs calling get_calendar_events_tool via structured JSON tool calling may provide max_results as a numeric string (e.g. "10"). Passing a string to ensure_capped(max_results, 50, ...) raises TypeError: '>' not supported between instances of 'str' and 'int'.
  3. Inverted Date Range Handling (time_max < time_min): If an agent or user requests an inverted range (end_date before start_date), the unvalidated dates are passed downstream to the Google Calendar API, resulting in HTTP 400 Bad Request (Invalid timeMin or timeMax). Furthermore, with search_query set, days_range < 180 silently shifts time_min = time_max - timedelta(days=180).
  4. Missing non-empty validation in create_calendar_event_tool: Calling create_calendar_event_tool with title=None or empty/whitespace strings proceeds to pass None or whitespace as the event summary, and start_time=None / end_time=None raises an unhandled AttributeError: 'NoneType' object has no attribute 'replace'.

Proposed Changes

  1. Safe Summary Attribute Access: Use (e.get('summary') or '').lower() in delete_calendar_event_tool and update_calendar_event_tool to prevent AttributeError on untitled events.
  2. Coerce and Bound max_results: Safely cast max_results to int and bound to 1..50 in get_calendar_events_tool.
  3. Validate Date Range Inversions: Return clear user-friendly error messages if time_max < time_min across all tools without firing failing API requests.
  4. Early String Validation: Validate title, start_time, and end_time in create_calendar_event_tool before ISO manipulation.
  5. Unit Test Coverage: Add comprehensive unit tests in backend/tests/unit/test_calendar_tools.py verifying each fix hermetically.

Bounty Proposal

  • Proposed Tier: $50
  • Payout Channel:
    • USDC (Polygon / Base / Arbitrum): 0xC345C07229307d4f1c7935aD2cAe48e390215808

Dimank92 avatar Oct 22 '26 03:10 Dimank92

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

Bounty Proposal & Claim

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

Dimank92 avatar Oct 22 '26 03: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