[Bounty Proposal] Validate inputs and use merge writes in database calendar meetings
Problem
-
NotFoundexception inupdate_meeting(backend/database/calendar_meetings.py:63):update_meetingexecutes:_get_meetings_collection(uid).document(meeting_id).update(meeting_data)If the target meeting document in
users/{uid}/meetings/{meeting_id}does not exist (for example, if purged by retention cleanup, deleted concurrently, or if an out-of-order calendar sync event arrives), Firestore raisesgoogle.api_core.exceptions.NotFound: 404 No document to update. This crashes calendar synchronization jobs and endpoints with an unhandled exception. -
Unchecked
KeyErrorincreate_meeting(backend/database/calendar_meetings.py:46):calendar_meeting_doc_id(uid, meeting_data['calendar_source'], meeting_data['calendar_event_id'])directly indexes'calendar_source'and'calendar_event_id', raising an unhandledKeyErrorif either attribute is omitted. -
Unhandled
AttributeErroron non-datetime in_to_utc(backend/database/calendar_meetings.py:98):_to_utcaccessesdt.tzinfowithout type validation. If a non-datetime value (such asNoneor an ISO string) is passed, Python raisesAttributeError: 'NoneType'/'str' object has no attribute 'tzinfo'. -
Missing parameter validation on
meeting_id:update_meetinganddelete_meetingdo not guard against emptymeeting_idstrings.
Proposed Solution
- Switch
update_meetingto_get_meetings_collection(uid).document(meeting_id).set(meeting_data, merge=True)for idempotent and resilient updates. - Validate required keys in
create_meeting,update_meeting, anddelete_meeting, raisingValueErroron missing identifiers. - Validate
isinstance(dt, datetime)in_to_utcwith explicitTypeError. - Add comprehensive regression tests in
backend/tests/unit/test_database_calendar_meetings_resilience.py.
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! 🙏