Skip to content

Fixes a notes data-loss bug where purgeAllSteps(fileID) ignored its fileID#4712

Merged
shepilov merged 2 commits intomasterfrom
fix/notes_step_was_removed
Apr 3, 2026
Merged

Fixes a notes data-loss bug where purgeAllSteps(fileID) ignored its fileID#4712
shepilov merged 2 commits intomasterfrom
fix/notes_step_was_removed

Conversation

@shepilov
Copy link
Copy Markdown
Contributor

Summary

This fixes a notes data-loss bug where purgeAllSteps(fileID) ignored its fileID argument and deleted step documents for all notes in io.cozy.notes.steps, not only the targeted note.

Bug story

We investigated a production incident where a user lost note content after a reload.

  • On Tuesday, the note 019d1f37-b201-7d8a-901d-39922cf7c647 accumulated a large number of unsaved note steps.
  • On Wednesday, Couch/stack logs showed a BulkDeleteDocs for io.cozy.notes.steps batch containing step IDs from multiple different notes.
  • In the stack code, purgeAllSteps(inst, fileID) was supposed to clear steps for one note after a schema update or .cozy-note overwrite/import.
  • But the implementation iterated the whole io.cozy.notes.steps database and deleted every step doc it found, regardless of fileID.

This means that an action on note B could wipe unsaved steps for note A.

The most likely production trigger is: overwrite/import of another existing .cozy-note file

@shepilov shepilov requested a review from a team as a code owner March 26, 2026 13:42
@shepilov shepilov changed the title Fix/notes step was removed Fixes a notes data-loss bug where purgeAllSteps(fileID) ignored its fileID Mar 26, 2026
@shepilov shepilov force-pushed the fix/notes_step_was_removed branch from b687e27 to b0f57ce Compare March 26, 2026 14:04
@shepilov shepilov merged commit 47f78fd into master Apr 3, 2026
4 checks passed
@shepilov shepilov deleted the fix/notes_step_was_removed branch April 3, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants