omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(notification-tools): coerce string hours, guard null action, and add error boundary in manage_daily_summary_tool ($50 proposed)

Open Dimank92 opened this issue 1 month ago • 1 comments

Summary

In backend/utils/retrieval/tools/notification_settings_tools.py, manage_daily_summary_tool() provides an agent tool interface for enabling, disabling, setting the local schedule hour, and querying the user's daily reflection notification settings.

Runtime Crashes & Vulnerabilities

  1. TypeError: '<=' not supported between instances of 'int' and 'str' and TypeError: '<' not supported between instances of 'str' and 'int': When LangChain model tool-calling outputs hour as a string (e.g. hour="22" or hour="8"), comparisons not (0 <= hour <= 23) and _format_hour(hour) (elif hour < 12:) crash with a fatal TypeError.
  2. AttributeError: 'NoneType' object has no attribute 'lower': If an LLM invocation omits action or passes action=None, action = action.lower().strip() raises an unhandled AttributeError outside any exception boundary.
  3. Missing Error Boundary for Storage Operations: Database calls notification_db.set_daily_summary_enabled() and notification_db.set_daily_summary_hour_local() are not enclosed in a try...except block, allowing transport/database timeouts and connection failures to crash the agent execution pipeline without sanitization.

Fix

  • Coerce hour safely via int(hour) with (TypeError, ValueError) guards in both _format_hour and the set_time action handler.
  • Guard action against None or non-string inputs before calling .lower().strip().
  • Add defensive fallback to extract uid from cfg.get('user_id') if not present in configurable.
  • Enclose storage actions in a sanitized try...except Exception as e: block with logger.error(..., exc_info=True).
  • Add comprehensive hermetic unit tests in backend/tests/unit/test_notification_settings_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 19: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