Bug: Deleting a user leaves shopping list items without any reason #35

Open
opened 2026-10-24 07:14:20 +00:00 by araemer · 0 comments
Owner

Problem

Deleting a user deletes every shopping list item reason that user added: shopping_list_item_reason.added_by is NOT NULL with ON DELETE CASCADE (src/entities/ShoppingListItemReasonEntity.ts, migration 1780012800011-CreateShoppingListItemReasonTable.ts).

An item whose only reason belonged to the deleted user is left with no reason at all. The contract (ShoppingListItemDto.reasons) promises "Always present with at least one entry". This affects items added by hand by a user who was later deleted, e.g. on a list shared with them, and from spec 004 on also items filled by them.

Found by the recipe-backend repo architect during /plan-feature for spec 004. It predates spec 004 (spec 001), so it is not fixed in that spec.

To decide

What a reason shows once its user is gone. For example: keep the reason with a nullable added_by and a "deleted user" display (that changes the contract, since addedBy is required today), or reassign it, or delete items left without a reason. A choice that changes the contract needs the cross-cutting architect.

🤖 Generated with Claude Code

## Problem Deleting a user deletes every shopping list item reason that user added: `shopping_list_item_reason.added_by` is `NOT NULL` with `ON DELETE CASCADE` (`src/entities/ShoppingListItemReasonEntity.ts`, migration `1780012800011-CreateShoppingListItemReasonTable.ts`). An item whose only reason belonged to the deleted user is left with **no reason at all**. The contract (`ShoppingListItemDto.reasons`) promises "Always present with at least one entry". This affects items added by hand by a user who was later deleted, e.g. on a list shared with them, and from spec 004 on also items filled by them. Found by the recipe-backend repo architect during `/plan-feature` for spec 004. It predates spec 004 (spec 001), so it is not fixed in that spec. ## To decide What a reason shows once its user is gone. For example: keep the reason with a nullable `added_by` and a "deleted user" display (that changes the contract, since `addedBy` is required today), or reassign it, or delete items left without a reason. A choice that changes the contract needs the cross-cutting architect. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
araemer changed title from Deleting a user leaves shopping list items without any reason to Bug: Deleting a user leaves shopping list items without any reason 2026-10-25 06:14:37 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
araemer/recipe-backend#35
No description provided.