add_inventory_item returns null product_name in create response #99

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

Summary

POST /api/v1/inventory/items returns product_name: null in the response even when the product exists.

Steps to reproduce

  1. Create a product via POST /api/v1/inventory/products
  2. Create an inventory item via POST /api/v1/inventory/items with the product_id
  3. Observe product_name is null in the response

Expected

product_name should be populated with the product name in the create response (same as GET responses).

Actual

{"id": 1, "product_id": 1, "product_name": null, ...}

Root cause

store.add_inventory_item uses INSERT ... RETURNING * which only returns inventory_items columns — no JOIN to products. The GET endpoints (get_inventory_item, list_inventory) both JOIN to products and return product_name correctly.

Fix

After the insert, call get_inventory_item(item["id"]) to return the joined row, or do a follow-up SELECT with JOIN.

## Summary `POST /api/v1/inventory/items` returns `product_name: null` in the response even when the product exists. ## Steps to reproduce 1. Create a product via `POST /api/v1/inventory/products` 2. Create an inventory item via `POST /api/v1/inventory/items` with the product_id 3. Observe `product_name` is null in the response ## Expected `product_name` should be populated with the product name in the create response (same as GET responses). ## Actual ```json {"id": 1, "product_id": 1, "product_name": null, ...} ``` ## Root cause `store.add_inventory_item` uses `INSERT ... RETURNING *` which only returns `inventory_items` columns — no JOIN to `products`. The GET endpoints (`get_inventory_item`, `list_inventory`) both JOIN to products and return `product_name` correctly. ## Fix After the insert, call `get_inventory_item(item["id"])` to return the joined row, or do a follow-up SELECT with JOIN.
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#99
No description provided.