omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty Proposal] Fix explicit None defaults and missing-doc crashes in user settings

Open Ariyachan opened this issue 2 months ago • 1 comments

Problem

  1. Explicit None settings default to disabled instead of enabled (backend/database/users.py:236-260): get_meeting_note_screenshots_enabled and get_user_private_cloud_sync_enabled previously used user_data.get(..., True). When an explicit None value is stored on a user document in Firestore (for example after a migration or partial settings update), dict.get(..., True) returns None. Consequently, callers evaluating if get_meeting_note_screenshots_enabled(uid): or if get_user_private_cloud_sync_enabled(uid): treat the returned None as False, incorrectly disabling features whose documented contract specifies default True.
  2. None serialization failure in get_notification_settings (backend/database/users.py:2253-2256): When users/{uid} has 'notifications_enabled': None or 'notification_frequency': None, get_notification_settings returned {'enabled': None, 'frequency': None}. The Swift client's NotificationSettingsResponse requires non-optional Bool and Int fields, causing JSON decoding errors. Furthermore, if doc.to_dict() returned None (on empty document snapshots), data.get(...) raised unhandled AttributeError.
  3. Unhandled AttributeError on empty document snapshots across settings and profile getters: In _get_raw_assistant_settings, get_assistant_settings, get_user_speaker_embedding, and _get_ai_user_profile_from_firestore, calling doc.to_dict().get(...) raised AttributeError: 'NoneType' object has no attribute 'get' whenever an existing document snapshot returned None for .to_dict().
  4. NotFound exceptions on uninitialized user documents: set_user_store_recording_permission, set_meeting_note_screenshots_enabled, and set_user_private_cloud_sync_enabled used .update(...), raising google.api_core.exceptions.NotFound when invoked for a user whose document has not yet been initialized in Firestore.

Proposed Solution

  • In get_meeting_note_screenshots_enabled and get_user_private_cloud_sync_enabled, return True when stored field value is None, while preserving explicit False.
  • In get_notification_settings, default enabled to True and frequency to 0 when fields are None, and guard doc.to_dict() with or {}.
  • Guard doc.to_dict() with or {} across settings and profile getters.
  • Use .set(..., merge=True) in user settings update methods.
  • Add unit tests in backend/tests/unit/test_users_settings_null_defaults.py.

Ariyachan avatar Sep 25 '26 17:09 Ariyachan

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