Edit item modal: purchase_date change is silently discarded #104

Closed
opened 2026-04-18 09:12:25 -07:00 by pyr0ball · 0 comments
Owner

Summary

The Edit Item modal has a Purchase Date field that accepts user input, but the PATCH request sends purchase_date which is not in the InventoryItemUpdate schema. Pydantic silently discards it, so purchase date changes never persist.

Steps to reproduce

  1. Add a pantry item without a purchase date
  2. Open Edit via the item menu
  3. Enter a purchase date and click Save
  4. Reopen the item — purchase date is still empty

Expected

The purchase date is saved and displayed on the item.

Actual

The PATCH request includes purchase_date in the body, but InventoryItemUpdate (Pydantic schema) does not declare this field. Pydantic v2 ignores unknown fields by default. The backend never receives the value.

Root cause

frontend/src/components/EditItemModal.vue line 177 constructs update.purchase_date = ... and sends it to PATCH /api/v1/inventory/items/{id}. But app/models/schemas/inventory.py InventoryItemUpdate does not include purchase_date, and store.update_inventory_item() does not include it in its allowed set either.

Fix

Add purchase_date: Optional[date] = None to InventoryItemUpdate and add "purchase_date" to the allowed set in store.update_inventory_item().

## Summary The Edit Item modal has a Purchase Date field that accepts user input, but the PATCH request sends `purchase_date` which is not in the `InventoryItemUpdate` schema. Pydantic silently discards it, so purchase date changes never persist. ## Steps to reproduce 1. Add a pantry item without a purchase date 2. Open Edit via the item menu 3. Enter a purchase date and click Save 4. Reopen the item — purchase date is still empty ## Expected The purchase date is saved and displayed on the item. ## Actual The PATCH request includes `purchase_date` in the body, but `InventoryItemUpdate` (Pydantic schema) does not declare this field. Pydantic v2 ignores unknown fields by default. The backend never receives the value. ## Root cause `frontend/src/components/EditItemModal.vue` line 177 constructs `update.purchase_date = ...` and sends it to `PATCH /api/v1/inventory/items/{id}`. But `app/models/schemas/inventory.py InventoryItemUpdate` does not include `purchase_date`, and `store.update_inventory_item()` does not include it in its `allowed` set either. ## Fix Add `purchase_date: Optional[date] = None` to `InventoryItemUpdate` and add `"purchase_date"` to the `allowed` set in `store.update_inventory_item()`.
Sign in to join this conversation.
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: Circuit-Forge/kiwi#104
No description provided.