bulk-add-by-name fails: source=shopping violates DB CHECK constraint #100
Labels
No labels
accessibility
backlog
beta-feedback
bug
duplicate
enhancement
feature-request
help wanted
invalid
needs-design
needs-triage
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Circuit-Forge/kiwi#100
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
POST /api/v1/inventory/items/bulk-add-by-namealways fails with a DB constraint error because it usessource="shopping"which is not in the allowed values.Steps to reproduce
POST /api/v1/inventory/items/bulk-add-by-namewith{"items": [{"name": "onion", "location": "pantry"}]}ok: falsefor every itemExpected
Items are created successfully.
Actual
Root cause
app/api/endpoints/inventory.pyline 187:get_or_create_product(..., source="shopping")but theproducts.sourcecolumn constraint isCHECK (source IN (\u2018openfoodfacts\u2019, \u2018manual\u2019, \u2018receipt_ocr\u2019)). Similarly line 195:add_inventory_item(..., source="shopping")butinventory_items.sourceconstraint isCHECK (source IN (\u2018barcode_scan\u2019, \u2018manual\u2019, \u2018receipt\u2019)).Fix
Change
source="shopping"tosource="manual"in both calls, or addshoppingto the CHECK constraint via a migration.