Repository navigation
fix(backend): cancel the replaced tasks' reminders when a conversation is reprocessed - #15180
Conversation
|
Bounty proposal for this fix: #15181 ($25 proposed). |
8196405 to
ef46b54
Compare
aryanorastar
left a comment
There was a problem hiding this comment.
Verified on ef46b545f3f9.
Two things before this can land:
-
The cancel loop sits between
delete_action_items_for_conversationandcreate_action_items_batchwith no try.sync_action_item_reminderends in FCM; if it raises, the old tasks are already gone and the new extraction is never written. Wrap the cancel (log and continue) so a reminder send cannot skip recreate — the merge/swipe-delete siblings already swallow that inside their existing except. -
Hygiene fails product-invariants:
process_conversation.pyis a locked path and the body never names INV-MEM-4 or INV-TASK-2. Add:
## Product invariants affected
- INV-MEM-4
- INV-TASK-2
The reprocess hole itself is real (main still drops old ids without a cancel). I am not merging.
|
Both points are addressed:
Re-requesting review at |
|
Verified both fixes from the prior review on
Two minor, non-blocking notes:
The hermetic test follows the existing unit-suite conventions (real writer, I/O seams recorded, first-processing negative case). Checks green including the hermetic backend gates. Nice fix — re-review from @aryanorastar needed to clear the prior change request on this head. 🤖 Automated review on behalf of the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
aryanorastar
left a comment
There was a problem hiding this comment.
Verified on cf7dbd4b12.
Both items from the earlier request are addressed:
- The reminder cancel sits in its own try/except between delete and
create_action_items_batch.test_a_failing_reminder_cancel_does_not_skip_the_new_taskspins that a raisingsync_action_item_reminderstill writes the new extraction. - The PR body names INV-MEM-4 and INV-TASK-2.
Gating matches the delete siblings (due_at and not completed). Current main still drops old ids without a cancel. I am not merging this SHA.
kodjima33
left a comment
There was a problem hiding this comment.
5/5 confidence: real bug (reprocessing a conversation replaces its tasks without cancelling the replaced rows' client-scheduled reminders, causing duplicate/stale reminders), same class as merged siblings (#15041/#15043/#14983/#15028), scoped with new regression tests that fail against origin/main; Hygiene/Formatting checks were stale cancelled runs, reran green, all CI now passing.
Summary
_write_action_items(the function that persists a conversation's extracted tasks) deletes every task the conversation wrote before and re-creates it under a fresh id, but never cancels the replaced rows' reminders.Impact
Reprocessing a conversation (
POST /v1/conversations/{id}/reprocess, or any re-run of processing) replaces its tasks: the old rows are deleted and the new extraction is created under new ids, with a reminder scheduled for each dated one (send_action_item_data_message). The deleted rows still owned client-scheduled local notifications, and the mobile client cancels those only on the backend's deletion data message (app/lib/services/notifications/action_item_notification_handler.dart→handleDeletionMessage). So after a reprocess:Same class as the sibling paths fixed in #15041 (conversation cascade delete), #15043 (developer API delete), #14983/#14984 (checking a task off inside a conversation) and #15028/#15029 (MCP task writes).
Fix
Read the previous rows before deleting them, then send
sync_action_item_reminder(..., completed=True, due_at=None)for each open dated row, gated exactly like the conversation-delete path.sync_action_item_reminderjoins the existingutils.notificationsimport at the top of the module; the old-ids list is derived from the same read, so no extra query.Tests
backend/tests/unit/test_write_action_items_cancels_replaced_reminders.py(new, hermetic: the real writer with every I/O seam recorded):Verification
Against
origin/mainprocess_conversation.pythe new positive test fails (sync_action_item_remindercalled 0 times).Failure-Class: none
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3187 -> 3207 | cancel the replaced rows' client-scheduled reminders inside the existing replacement block; the old-ids read already existed, so the growth is the cancel loop and its comment
Product invariants affected
Neither invariant is altered: this change does not touch memory intake or promotion,
and it does not add or route any capture-to-task path. It only cancels the mobile
client's already-scheduled reminder for rows that were deleted through the existing
replacement writer.